diff options
author | Michael Holzheu <holzheu@de.ibm.com> | 2008-04-17 01:46:18 -0400 |
---|---|---|
committer | Heiko Carstens <heiko.carstens@de.ibm.com> | 2008-04-17 01:47:03 -0400 |
commit | 9637c3f318374e2fcc37e354f9782a705b517387 (patch) | |
tree | b030280d2f0101e4cdbcf5bbd6518213eacd65aa /arch/s390/kernel | |
parent | 9f7819c1e51d5310d012426599a5f49d8678119d (diff) |
[S390] Add debug_register_mode() function to debug feature API
The new function supports setting of permissions for the debugfs files
created by the debug feature. In addition to that, the function provides
uid and gid as parameters for future use. Currently only root is allowed
for uid and gid.
Signed-off-by: Michael Holzheu <holzheu@de.ibm.com>
Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com>
Diffstat (limited to 'arch/s390/kernel')
-rw-r--r-- | arch/s390/kernel/debug.c | 51 |
1 files changed, 38 insertions, 13 deletions
diff --git a/arch/s390/kernel/debug.c b/arch/s390/kernel/debug.c index 1b2f5ce45320..95a46bc008b7 100644 --- a/arch/s390/kernel/debug.c +++ b/arch/s390/kernel/debug.c | |||
@@ -73,7 +73,7 @@ static ssize_t debug_input(struct file *file, const char __user *user_buf, | |||
73 | static int debug_open(struct inode *inode, struct file *file); | 73 | static int debug_open(struct inode *inode, struct file *file); |
74 | static int debug_close(struct inode *inode, struct file *file); | 74 | static int debug_close(struct inode *inode, struct file *file); |
75 | static debug_info_t* debug_info_create(char *name, int pages_per_area, | 75 | static debug_info_t* debug_info_create(char *name, int pages_per_area, |
76 | int nr_areas, int buf_size); | 76 | int nr_areas, int buf_size, mode_t mode); |
77 | static void debug_info_get(debug_info_t *); | 77 | static void debug_info_get(debug_info_t *); |
78 | static void debug_info_put(debug_info_t *); | 78 | static void debug_info_put(debug_info_t *); |
79 | static int debug_prolog_level_fn(debug_info_t * id, | 79 | static int debug_prolog_level_fn(debug_info_t * id, |
@@ -327,7 +327,8 @@ debug_info_free(debug_info_t* db_info){ | |||
327 | */ | 327 | */ |
328 | 328 | ||
329 | static debug_info_t* | 329 | static debug_info_t* |
330 | debug_info_create(char *name, int pages_per_area, int nr_areas, int buf_size) | 330 | debug_info_create(char *name, int pages_per_area, int nr_areas, int buf_size, |
331 | mode_t mode) | ||
331 | { | 332 | { |
332 | debug_info_t* rc; | 333 | debug_info_t* rc; |
333 | 334 | ||
@@ -336,6 +337,8 @@ debug_info_create(char *name, int pages_per_area, int nr_areas, int buf_size) | |||
336 | if(!rc) | 337 | if(!rc) |
337 | goto out; | 338 | goto out; |
338 | 339 | ||
340 | rc->mode = mode & ~S_IFMT; | ||
341 | |||
339 | /* create root directory */ | 342 | /* create root directory */ |
340 | rc->debugfs_root_entry = debugfs_create_dir(rc->name, | 343 | rc->debugfs_root_entry = debugfs_create_dir(rc->name, |
341 | debug_debugfs_root_entry); | 344 | debug_debugfs_root_entry); |
@@ -676,23 +679,30 @@ debug_close(struct inode *inode, struct file *file) | |||
676 | } | 679 | } |
677 | 680 | ||
678 | /* | 681 | /* |
679 | * debug_register: | 682 | * debug_register_mode: |
680 | * - creates and initializes debug area for the caller | 683 | * - Creates and initializes debug area for the caller |
681 | * - returns handle for debug area | 684 | * The mode parameter allows to specify access rights for the s390dbf files |
685 | * - Returns handle for debug area | ||
682 | */ | 686 | */ |
683 | 687 | ||
684 | debug_info_t* | 688 | debug_info_t *debug_register_mode(char *name, int pages_per_area, int nr_areas, |
685 | debug_register (char *name, int pages_per_area, int nr_areas, int buf_size) | 689 | int buf_size, mode_t mode, uid_t uid, |
690 | gid_t gid) | ||
686 | { | 691 | { |
687 | debug_info_t *rc = NULL; | 692 | debug_info_t *rc = NULL; |
688 | 693 | ||
694 | /* Since debugfs currently does not support uid/gid other than root, */ | ||
695 | /* we do not allow gid/uid != 0 until we get support for that. */ | ||
696 | if ((uid != 0) || (gid != 0)) | ||
697 | printk(KERN_WARNING "debug: Warning - Currently only uid/gid " | ||
698 | "= 0 are supported. Using root as owner now!"); | ||
689 | if (!initialized) | 699 | if (!initialized) |
690 | BUG(); | 700 | BUG(); |
691 | mutex_lock(&debug_mutex); | 701 | mutex_lock(&debug_mutex); |
692 | 702 | ||
693 | /* create new debug_info */ | 703 | /* create new debug_info */ |
694 | 704 | ||
695 | rc = debug_info_create(name, pages_per_area, nr_areas, buf_size); | 705 | rc = debug_info_create(name, pages_per_area, nr_areas, buf_size, mode); |
696 | if(!rc) | 706 | if(!rc) |
697 | goto out; | 707 | goto out; |
698 | debug_register_view(rc, &debug_level_view); | 708 | debug_register_view(rc, &debug_level_view); |
@@ -705,6 +715,20 @@ out: | |||
705 | mutex_unlock(&debug_mutex); | 715 | mutex_unlock(&debug_mutex); |
706 | return rc; | 716 | return rc; |
707 | } | 717 | } |
718 | EXPORT_SYMBOL(debug_register_mode); | ||
719 | |||
720 | /* | ||
721 | * debug_register: | ||
722 | * - creates and initializes debug area for the caller | ||
723 | * - returns handle for debug area | ||
724 | */ | ||
725 | |||
726 | debug_info_t *debug_register(char *name, int pages_per_area, int nr_areas, | ||
727 | int buf_size) | ||
728 | { | ||
729 | return debug_register_mode(name, pages_per_area, nr_areas, buf_size, | ||
730 | S_IRUSR | S_IWUSR, 0, 0); | ||
731 | } | ||
708 | 732 | ||
709 | /* | 733 | /* |
710 | * debug_unregister: | 734 | * debug_unregister: |
@@ -1073,15 +1097,16 @@ debug_register_view(debug_info_t * id, struct debug_view *view) | |||
1073 | int rc = 0; | 1097 | int rc = 0; |
1074 | int i; | 1098 | int i; |
1075 | unsigned long flags; | 1099 | unsigned long flags; |
1076 | mode_t mode = S_IFREG; | 1100 | mode_t mode; |
1077 | struct dentry *pde; | 1101 | struct dentry *pde; |
1078 | 1102 | ||
1079 | if (!id) | 1103 | if (!id) |
1080 | goto out; | 1104 | goto out; |
1081 | if (view->prolog_proc || view->format_proc || view->header_proc) | 1105 | mode = (id->mode | S_IFREG) & ~S_IXUGO; |
1082 | mode |= S_IRUSR; | 1106 | if (!(view->prolog_proc || view->format_proc || view->header_proc)) |
1083 | if (view->input_proc) | 1107 | mode &= ~(S_IRUSR | S_IRGRP | S_IROTH); |
1084 | mode |= S_IWUSR; | 1108 | if (!view->input_proc) |
1109 | mode &= ~(S_IWUSR | S_IWGRP | S_IWOTH); | ||
1085 | pde = debugfs_create_file(view->name, mode, id->debugfs_root_entry, | 1110 | pde = debugfs_create_file(view->name, mode, id->debugfs_root_entry, |
1086 | id , &debug_file_ops); | 1111 | id , &debug_file_ops); |
1087 | if (!pde){ | 1112 | if (!pde){ |