diff options
author | Alexey Dobriyan <adobriyan@gmail.com> | 2008-04-29 04:01:40 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2008-04-29 11:06:17 -0400 |
commit | 7cee4e00e0f8aa7290266382ea903a5a1b92c9a1 (patch) | |
tree | 3d4ca2241e122f3358433b26538d952eda0226c5 /fs/proc/generic.c | |
parent | f649d6d32605c7573884613289fb3b9fbd4f99a1 (diff) |
proc: less special case in xlate code
If valid "parent" is passed to proc_create/remove_proc_entry(), then name of
PDE should consist of only one path component, otherwise creation or or
removal will fail. However, if NULL is passed as parent then create/remove
accept full path as a argument. This is arbitrary restriction -- all
infrastructure is in place.
So, patch allows the following to succeed:
create_proc_entry("foo/bar", 0, pde_baz);
remove_proc_entry("baz/foo/bar", &proc_root);
Also makes the following to behave identically:
create_proc_entry("foo/bar", 0, NULL);
create_proc_entry("foo/bar", 0, &proc_root);
Discrepancy noticed by Den Lunev (IIRC).
Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'fs/proc/generic.c')
-rw-r--r-- | fs/proc/generic.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/fs/proc/generic.c b/fs/proc/generic.c index 45d0076bc08e..3c6f5669523a 100644 --- a/fs/proc/generic.c +++ b/fs/proc/generic.c | |||
@@ -277,8 +277,11 @@ static int xlate_proc_name(const char *name, | |||
277 | int len; | 277 | int len; |
278 | int rtn = 0; | 278 | int rtn = 0; |
279 | 279 | ||
280 | de = *ret; | ||
281 | if (!de) | ||
282 | de = &proc_root; | ||
283 | |||
280 | spin_lock(&proc_subdir_lock); | 284 | spin_lock(&proc_subdir_lock); |
281 | de = &proc_root; | ||
282 | while (1) { | 285 | while (1) { |
283 | next = strchr(cp, '/'); | 286 | next = strchr(cp, '/'); |
284 | if (!next) | 287 | if (!next) |
@@ -582,7 +585,7 @@ static struct proc_dir_entry *__proc_create(struct proc_dir_entry **parent, | |||
582 | /* make sure name is valid */ | 585 | /* make sure name is valid */ |
583 | if (!name || !strlen(name)) goto out; | 586 | if (!name || !strlen(name)) goto out; |
584 | 587 | ||
585 | if (!(*parent) && xlate_proc_name(name, parent, &fn) != 0) | 588 | if (xlate_proc_name(name, parent, &fn) != 0) |
586 | goto out; | 589 | goto out; |
587 | 590 | ||
588 | /* At this point there must not be any '/' characters beyond *fn */ | 591 | /* At this point there must not be any '/' characters beyond *fn */ |
@@ -738,7 +741,7 @@ void remove_proc_entry(const char *name, struct proc_dir_entry *parent) | |||
738 | const char *fn = name; | 741 | const char *fn = name; |
739 | int len; | 742 | int len; |
740 | 743 | ||
741 | if (!parent && xlate_proc_name(name, &parent, &fn) != 0) | 744 | if (xlate_proc_name(name, &parent, &fn) != 0) |
742 | return; | 745 | return; |
743 | len = strlen(fn); | 746 | len = strlen(fn); |
744 | 747 | ||