patch-2.0.35 linux/kernel/sysctl.c
Next file: linux/mm/page_alloc.c
Previous file: linux/kernel/sched.c
Back to the patch index
Back to the overall index
- Lines: 59
- Date:
Mon Jul 13 13:47:40 1998
- Orig file:
v2.0.34/linux/kernel/sysctl.c
- Orig date:
Mon Jul 13 13:46:42 1998
diff -u --recursive --new-file v2.0.34/linux/kernel/sysctl.c linux/kernel/sysctl.c
@@ -397,9 +397,11 @@
/* Scan the sysctl entries in table and add them all into /proc */
static void register_proc_table(ctl_table * table, struct proc_dir_entry *root)
{
- struct proc_dir_entry *de;
+ struct proc_dir_entry *de, *tmp;
+ int exists;
for (; table->ctl_name; table++) {
+ exists = 0;
/* Can't do anything without a proc name. */
if (!table->procname)
continue;
@@ -428,12 +430,24 @@
}
/* Otherwise it's a subdir */
else {
- de->ops = &proc_dir_inode_operations;
- de->nlink++;
- de->mode |= S_IFDIR;
+ /* First check to see if it already exists */
+ for (tmp = root->subdir; tmp; tmp = tmp->next) {
+ if (tmp->namelen == de->namelen &&
+ !memcmp(tmp->name,de->name,de->namelen)) {
+ exists = 1;
+ kfree (de);
+ de = tmp;
+ }
+ }
+ if (!exists) {
+ de->ops = &proc_dir_inode_operations;
+ de->nlink++;
+ de->mode |= S_IFDIR;
+ }
}
table->de = de;
- proc_register_dynamic(root, de);
+ if (!exists)
+ proc_register_dynamic(root, de);
if (de->mode & S_IFDIR )
register_proc_table(table->child, de);
}
@@ -452,9 +466,13 @@
}
unregister_proc_table(table->child, de);
}
- proc_unregister(root, de->low_ino);
- table->de = NULL;
- kfree(de);
+ /* Don't unregister proc directories which still have
+ entries... */
+ if (!((de->mode & S_IFDIR) && de->subdir)) {
+ proc_unregister(root, de->low_ino);
+ table->de = NULL;
+ kfree(de);
+ }
}
}
FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen, slshen@lbl.gov