Skip to content

Commit

Permalink
sysctl: Add sysctl_print_dir and use it in get_subdir
Browse files Browse the repository at this point in the history
When there are errors it is very nice to know the full sysctl path.
Add a simple function that computes the sysctl path and prints it
out.

Signed-off-by: Eric W. Biederman <[email protected]>
  • Loading branch information
ebiederm committed Jan 25, 2012
1 parent 7ec66d0 commit 6980128
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion fs/proc/proc_sysctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,13 @@ static DEFINE_SPINLOCK(sysctl_lock);

static void drop_sysctl_table(struct ctl_table_header *header);

static void sysctl_print_dir(struct ctl_dir *dir)
{
if (dir->header.parent)
sysctl_print_dir(dir->header.parent);
printk(KERN_CONT "%s/", dir->header.ctl_table[0].procname);
}

static int namecmp(const char *name1, int len1, const char *name2, int len2)
{
int minlen;
Expand Down Expand Up @@ -822,7 +829,9 @@ static struct ctl_dir *get_subdir(struct ctl_table_set *set,
subdir->header.nreg++;
failed:
if (unlikely(IS_ERR(subdir))) {
printk(KERN_ERR "sysctl could not get directory: %*.*s %ld\n",
printk(KERN_ERR "sysctl could not get directory: ");
sysctl_print_dir(dir);
printk(KERN_CONT "/%*.*s %ld\n",
namelen, namelen, name, PTR_ERR(subdir));
}
drop_sysctl_table(&dir->header);
Expand Down

0 comments on commit 6980128

Please sign in to comment.