Skip to content

Commit 6980128

Browse files
committed
sysctl: Add sysctl_print_dir and use it in get_subdir
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 <ebiederm@xmission.com>
1 parent 7ec66d0 commit 6980128

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

fs/proc/proc_sysctl.c

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,13 @@ static DEFINE_SPINLOCK(sysctl_lock);
5353

5454
static void drop_sysctl_table(struct ctl_table_header *header);
5555

56+
static void sysctl_print_dir(struct ctl_dir *dir)
57+
{
58+
if (dir->header.parent)
59+
sysctl_print_dir(dir->header.parent);
60+
printk(KERN_CONT "%s/", dir->header.ctl_table[0].procname);
61+
}
62+
5663
static int namecmp(const char *name1, int len1, const char *name2, int len2)
5764
{
5865
int minlen;
@@ -822,7 +829,9 @@ static struct ctl_dir *get_subdir(struct ctl_table_set *set,
822829
subdir->header.nreg++;
823830
failed:
824831
if (unlikely(IS_ERR(subdir))) {
825-
printk(KERN_ERR "sysctl could not get directory: %*.*s %ld\n",
832+
printk(KERN_ERR "sysctl could not get directory: ");
833+
sysctl_print_dir(dir);
834+
printk(KERN_CONT "/%*.*s %ld\n",
826835
namelen, namelen, name, PTR_ERR(subdir));
827836
}
828837
drop_sysctl_table(&dir->header);

0 commit comments

Comments
 (0)