aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEric W. Biederman <ebiederm@xmission.com>2007-02-14 03:34:13 -0500
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2007-02-14 11:10:00 -0500
commitd912b0cc1a617d7c590d57b7ea971d50c7f02503 (patch)
tree04cfb8553ffc3ac054e42af56ce7f3246005097c
parent77b14db502cb85a031fe8fde6c85d52f3e0acb63 (diff)
[PATCH] sysctl: add a parent entry to ctl_table and set the parent entry
Add a parent entry into the ctl_table so you can walk the list of parents and find the entire path to a ctl_table entry. Signed-off-by: Eric W. Biederman <ebiederm@xmission.com> Cc: Stephen Smalley <sds@tycho.nsa.gov> Cc: James Morris <jmorris@namei.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r--include/linux/sysctl.h1
-rw-r--r--kernel/sysctl.c18
2 files changed, 19 insertions, 0 deletions
diff --git a/include/linux/sysctl.h b/include/linux/sysctl.h
index 89150494bd10..1371d7b86810 100644
--- a/include/linux/sysctl.h
+++ b/include/linux/sysctl.h
@@ -1022,6 +1022,7 @@ struct ctl_table
1022 int maxlen; 1022 int maxlen;
1023 mode_t mode; 1023 mode_t mode;
1024 ctl_table *child; 1024 ctl_table *child;
1025 ctl_table *parent; /* Automatically set */
1025 proc_handler *proc_handler; /* Callback for text formatting */ 1026 proc_handler *proc_handler; /* Callback for text formatting */
1026 ctl_handler *strategy; /* Callback function for all r/w */ 1027 ctl_handler *strategy; /* Callback function for all r/w */
1027 struct proc_dir_entry *de; /* /proc control block */ 1028 struct proc_dir_entry *de; /* /proc control block */
diff --git a/kernel/sysctl.c b/kernel/sysctl.c
index b3ee791ad663..3ca1d5ff0319 100644
--- a/kernel/sysctl.c
+++ b/kernel/sysctl.c
@@ -1240,6 +1240,23 @@ int do_sysctl_strategy (ctl_table *table,
1240} 1240}
1241#endif /* CONFIG_SYSCTL_SYSCALL */ 1241#endif /* CONFIG_SYSCTL_SYSCALL */
1242 1242
1243static void sysctl_set_parent(struct ctl_table *parent, struct ctl_table *table)
1244{
1245 for (; table->ctl_name || table->procname; table++) {
1246 table->parent = parent;
1247 if (table->child)
1248 sysctl_set_parent(table, table->child);
1249 }
1250}
1251
1252static __init int sysctl_init(void)
1253{
1254 sysctl_set_parent(NULL, root_table);
1255 return 0;
1256}
1257
1258core_initcall(sysctl_init);
1259
1243/** 1260/**
1244 * register_sysctl_table - register a sysctl hierarchy 1261 * register_sysctl_table - register a sysctl hierarchy
1245 * @table: the top-level table structure 1262 * @table: the top-level table structure
@@ -1318,6 +1335,7 @@ struct ctl_table_header *register_sysctl_table(ctl_table * table)
1318 INIT_LIST_HEAD(&tmp->ctl_entry); 1335 INIT_LIST_HEAD(&tmp->ctl_entry);
1319 tmp->used = 0; 1336 tmp->used = 0;
1320 tmp->unregistering = NULL; 1337 tmp->unregistering = NULL;
1338 sysctl_set_parent(NULL, table);
1321 spin_lock(&sysctl_lock); 1339 spin_lock(&sysctl_lock);
1322 list_add_tail(&tmp->ctl_entry, &root_table_header.ctl_entry); 1340 list_add_tail(&tmp->ctl_entry, &root_table_header.ctl_entry);
1323 spin_unlock(&sysctl_lock); 1341 spin_unlock(&sysctl_lock);