[PATCH 1/2] sysctl: Add a parent entry to ctl_table and set the parent entry.

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Eric W. Biederman
Date: Tuesday, February 6, 2007 - 2:16 pm

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>
---

This is an incremental patch on top of my previous sysctl work.

 include/linux/sysctl.h |    1 +
 kernel/sysctl.c        |   10 ++++++++++
 2 files changed, 11 insertions(+), 0 deletions(-)

diff --git a/include/linux/sysctl.h b/include/linux/sysctl.h
index 286e723..24f36f1 100644
--- a/include/linux/sysctl.h
+++ b/include/linux/sysctl.h
@@ -1024,6 +1024,7 @@ struct ctl_table
 	int maxlen;
 	mode_t mode;
 	ctl_table *child;
+	ctl_table *parent;		/* Automatically set */
 	proc_handler *proc_handler;	/* Callback for text formatting */
 	ctl_handler *strategy;		/* Callback function for all r/w */
 	void *extra1;
diff --git a/kernel/sysctl.c b/kernel/sysctl.c
index ae6a424..0a5499f 100644
--- a/kernel/sysctl.c
+++ b/kernel/sysctl.c
@@ -1232,6 +1232,15 @@ int do_sysctl_strategy (ctl_table *table,
 }
 #endif /* CONFIG_SYSCTL_SYSCALL */
 
+static void sysctl_set_parent(struct ctl_table *parent, struct ctl_table *table)
+{
+	for (; table->ctl_name || table->procname; table++) {
+		table->parent = parent;
+		if (table->child)
+			sysctl_set_parent(table, table->child);
+	}
+}
+
 /**
  * register_sysctl_table - register a sysctl hierarchy
  * @table: the top-level table structure
@@ -1311,6 +1320,7 @@ static struct ctl_table_header *__register_sysctl_table(
 	INIT_LIST_HEAD(&tmp->ctl_entry);
 	tmp->used = 0;
 	tmp->unregistering = NULL;
+	sysctl_set_parent(NULL, table);
 	spin_lock(&sysctl_lock);
 	list_add_tail(&tmp->ctl_entry, &root->ctl_entry);
 	spin_unlock(&sysctl_lock);
-- 
1.4.4.1.g278f

-
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[PATCH] sysctl selinux: Don't look at table-&gt;de, Eric W. Biederman, (Sun Jan 28, 12:21 pm)
Re: [PATCH] sysctl selinux: Don't look at table-&gt;de, Stephen Smalley, (Mon Jan 29, 6:04 am)
Re: [PATCH] sysctl selinux: Don't look at table-&gt;de, James Morris, (Mon Jan 29, 8:23 am)
Re: [PATCH] sysctl selinux: Don't look at table-&gt;de, Eric W. Biederman, (Mon Jan 29, 10:43 am)
Re: [PATCH] sysctl selinux: Don't look at table-&gt;de, Eric W. Biederman, (Mon Jan 29, 10:55 am)
Re: [PATCH] sysctl selinux: Don't look at table-&gt;de, Stephen Smalley, (Mon Jan 29, 11:43 am)
Re: [PATCH] sysctl selinux: Don't look at table-&gt;de, Casey Schaufler, (Mon Jan 29, 12:08 pm)
Re: [PATCH] sysctl selinux: Don't look at table-&gt;de, Eric W. Biederman, (Mon Jan 29, 12:16 pm)
Re: [PATCH] sysctl selinux: Don't look at table-&gt;de, Stephen Smalley, (Mon Jan 29, 12:26 pm)
Re: [PATCH] sysctl selinux: Don't look at table-&gt;de, Stephen Smalley, (Mon Jan 29, 1:07 pm)
Re: [PATCH] sysctl selinux: Don't look at table-&gt;de, Russell Coker, (Mon Jan 29, 4:28 pm)
Re: [PATCH] sysctl selinux: Don't look at table-&gt;de, Christoph Hellwig, (Tue Jan 30, 3:25 am)
Re: [PATCH] sysctl selinux: Don't look at table-&gt;de, Casey Schaufler, (Tue Jan 30, 10:19 am)
[PATCH 1/2] sysctl: Add a parent entry to ctl_table and se ..., Eric W. Biederman, (Tue Feb 6, 2:16 pm)
Re: [PATCH 2/2] sysctl: Restore the selinux path based lab ..., Eric W. Biederman, (Thu Feb 8, 10:53 am)
[PATCH 0/5] sysctl cleanup selinux fixes, Eric W. Biederman, (Thu Feb 8, 3:51 pm)
[PATCH 1/5] sysctl: Remove declaration of nonexistent sys ..., Eric W. Biederman, (Thu Feb 8, 3:53 pm)
[PATCH 3/5] sysctl: Fix the selinux_sysctl_get_sid, Eric W. Biederman, (Thu Feb 8, 3:55 pm)
[PATCH 5/5] sysctl: Hide the sysctl proc inodes from selinux., Eric W. Biederman, (Thu Feb 8, 4:04 pm)
Re: [PATCH 0/5] sysctl cleanup selinux fixes, Andrew Morton, (Fri Feb 9, 4:05 am)
Re: [PATCH 3/5] sysctl: Fix the selinux_sysctl_get_sid, Stephen Smalley, (Fri Feb 9, 5:24 am)
Re: [PATCH 0/5] sysctl cleanup selinux fixes, Eric W. Biederman, (Fri Feb 9, 11:09 am)