Skip to content

Commit

Permalink
[PATCH] sysctl: remove insert_at_head from register_sysctl
Browse files Browse the repository at this point in the history
The semantic effect of insert_at_head is that it would allow new registered
sysctl entries to override existing sysctl entries of the same name.  Which is
pain for caching and the proc interface never implemented.

I have done an audit and discovered that none of the current users of
register_sysctl care as (excpet for directories) they do not register
duplicate sysctl entries.

So this patch simply removes the support for overriding existing entries in
the sys_sysctl interface since no one uses it or cares and it makes future
enhancments harder.

Signed-off-by: Eric W. Biederman <ebiederm@xmission.com>
Acked-by: Ralf Baechle <ralf@linux-mips.org>
Acked-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
Cc: Russell King <rmk@arm.linux.org.uk>
Cc: David Howells <dhowells@redhat.com>
Cc: "Luck, Tony" <tony.luck@intel.com>
Cc: Ralf Baechle <ralf@linux-mips.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Martin Schwidefsky <schwidefsky@de.ibm.com>
Cc: Andi Kleen <ak@muc.de>
Cc: Jens Axboe <axboe@kernel.dk>
Cc: Corey Minyard <minyard@acm.org>
Cc: Neil Brown <neilb@suse.de>
Cc: "John W. Linville" <linville@tuxdriver.com>
Cc: James Bottomley <James.Bottomley@steeleye.com>
Cc: Jan Kara <jack@ucw.cz>
Cc: Trond Myklebust <trond.myklebust@fys.uio.no>
Cc: Mark Fasheh <mark.fasheh@oracle.com>
Cc: David Chinner <dgc@sgi.com>
Cc: "David S. Miller" <davem@davemloft.net>
Cc: Patrick McHardy <kaber@trash.net>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
  • Loading branch information
ebiederm authored and Linus Torvalds committed Feb 14, 2007
1 parent ae83681 commit 0b4d414
Show file tree
Hide file tree
Showing 68 changed files with 75 additions and 80 deletions.
2 changes: 1 addition & 1 deletion arch/arm/kernel/isa.c
Original file line number Diff line number Diff line change
Expand Up @@ -70,5 +70,5 @@ register_isa_ports(unsigned int membase, unsigned int portbase, unsigned int por
isa_membase = membase;
isa_portbase = portbase;
isa_portshift = portshift;
isa_sysctl_header = register_sysctl_table(ctl_bus, 0);
isa_sysctl_header = register_sysctl_table(ctl_bus);
}
2 changes: 1 addition & 1 deletion arch/frv/kernel/pm.c
Original file line number Diff line number Diff line change
Expand Up @@ -455,7 +455,7 @@ static struct ctl_table pm_dir_table[] =
*/
static int __init pm_init(void)
{
register_sysctl_table(pm_dir_table, 0);
register_sysctl_table(pm_dir_table);
return 0;
}

Expand Down
2 changes: 1 addition & 1 deletion arch/frv/kernel/sysctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ static struct ctl_table frv_dir_table[] =
*/
static int __init frv_sysctl_init(void)
{
register_sysctl_table(frv_dir_table, 0);
register_sysctl_table(frv_dir_table);
return 0;
}

Expand Down
2 changes: 1 addition & 1 deletion arch/ia64/kernel/crash.c
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ machine_crash_setup(void)
if((ret = register_die_notifier(&kdump_init_notifier_nb)) != 0)
return ret;
#ifdef CONFIG_SYSCTL
register_sysctl_table(sys_table, 0);
register_sysctl_table(sys_table);
#endif
return 0;
}
Expand Down
2 changes: 1 addition & 1 deletion arch/ia64/kernel/perfmon.c
Original file line number Diff line number Diff line change
Expand Up @@ -6726,7 +6726,7 @@ pfm_init(void)
/*
* create /proc/sys/kernel/perfmon (for debugging purposes)
*/
pfm_sysctl_header = register_sysctl_table(pfm_sysctl_root, 0);
pfm_sysctl_header = register_sysctl_table(pfm_sysctl_root);

/*
* initialize all our spinlocks
Expand Down
2 changes: 1 addition & 1 deletion arch/ia64/sn/kernel/xpc_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -1241,7 +1241,7 @@ xpc_init(void)
snprintf(xpc_part->bus_id, BUS_ID_SIZE, "part");
snprintf(xpc_chan->bus_id, BUS_ID_SIZE, "chan");

xpc_sysctl = register_sysctl_table(xpc_sys_dir, 0);
xpc_sysctl = register_sysctl_table(xpc_sys_dir);

/*
* The first few fields of each entry of xpc_partitions[] need to
Expand Down
2 changes: 1 addition & 1 deletion arch/mips/au1000/common/power.c
Original file line number Diff line number Diff line change
Expand Up @@ -461,7 +461,7 @@ static struct ctl_table pm_dir_table[] = {
*/
static int __init pm_init(void)
{
register_sysctl_table(pm_dir_table, 0);
register_sysctl_table(pm_dir_table);
return 0;
}

Expand Down
2 changes: 1 addition & 1 deletion arch/mips/lasat/sysctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,7 @@ static int __init lasat_register_sysctl(void)
struct ctl_table_header *lasat_table_header;

lasat_table_header =
register_sysctl_table(lasat_root_table, 0);
register_sysctl_table(lasat_root_table);

return 0;
}
Expand Down
2 changes: 1 addition & 1 deletion arch/powerpc/kernel/idle.c
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ static ctl_table powersave_nap_sysctl_root[] = {
static int __init
register_powersave_nap_sysctl(void)
{
register_sysctl_table(powersave_nap_sysctl_root, 0);
register_sysctl_table(powersave_nap_sysctl_root);

return 0;
}
Expand Down
2 changes: 1 addition & 1 deletion arch/ppc/kernel/ppc_htab.c
Original file line number Diff line number Diff line change
Expand Up @@ -457,7 +457,7 @@ static ctl_table htab_sysctl_root[] = {
static int __init
register_ppc_htab_sysctl(void)
{
register_sysctl_table(htab_sysctl_root, 0);
register_sysctl_table(htab_sysctl_root);

return 0;
}
Expand Down
4 changes: 2 additions & 2 deletions arch/s390/appldata/appldata_base.c
Original file line number Diff line number Diff line change
Expand Up @@ -506,7 +506,7 @@ int appldata_register_ops(struct appldata_ops *ops)

ops->ctl_table[3].ctl_name = 0;

ops->sysctl_header = register_sysctl_table(ops->ctl_table,0);
ops->sysctl_header = register_sysctl_table(ops->ctl_table);

P_INFO("%s-ops registered!\n", ops->name);
return 0;
Expand Down Expand Up @@ -606,7 +606,7 @@ static int __init appldata_init(void)
/* Register cpu hotplug notifier */
register_hotcpu_notifier(&appldata_nb);

appldata_sysctl_header = register_sysctl_table(appldata_dir_table, 0);
appldata_sysctl_header = register_sysctl_table(appldata_dir_table);
#ifdef MODULE
appldata_dir_table[0].de->owner = THIS_MODULE;
appldata_table[0].de->owner = THIS_MODULE;
Expand Down
2 changes: 1 addition & 1 deletion arch/s390/kernel/debug.c
Original file line number Diff line number Diff line change
Expand Up @@ -1053,7 +1053,7 @@ __init debug_init(void)
{
int rc = 0;

s390dbf_sysctl_header = register_sysctl_table(s390dbf_dir_table, 0);
s390dbf_sysctl_header = register_sysctl_table(s390dbf_dir_table);
down(&debug_lock);
debug_debugfs_root_entry = debugfs_create_dir(DEBUG_DIR_ROOT,NULL);
printk(KERN_INFO "debug: Initialization complete\n");
Expand Down
2 changes: 1 addition & 1 deletion arch/s390/mm/cmm.c
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,7 @@ cmm_init (void)
int rc = -ENOMEM;

#ifdef CONFIG_CMM_PROC
cmm_sysctl_header = register_sysctl_table(cmm_dir_table, 0);
cmm_sysctl_header = register_sysctl_table(cmm_dir_table);
if (!cmm_sysctl_header)
goto out;
#endif
Expand Down
2 changes: 1 addition & 1 deletion arch/sh64/kernel/traps.c
Original file line number Diff line number Diff line change
Expand Up @@ -960,7 +960,7 @@ static ctl_table sh64_root[] = {
static struct ctl_table_header *sysctl_header;
static int __init init_sysctl(void)
{
sysctl_header = register_sysctl_table(sh64_root, 0);
sysctl_header = register_sysctl_table(sh64_root);
return 0;
}

Expand Down
2 changes: 1 addition & 1 deletion arch/x86_64/ia32/ia32_binfmt.c
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ static ctl_table abi_root_table2[] = {

static __init int ia32_binfmt_init(void)
{
register_sysctl_table(abi_root_table2, 0);
register_sysctl_table(abi_root_table2);
return 0;
}
__initcall(ia32_binfmt_init);
Expand Down
2 changes: 1 addition & 1 deletion arch/x86_64/kernel/vsyscall.c
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ static int __init vsyscall_init(void)
BUG_ON((unsigned long) &vgetcpu != VSYSCALL_ADDR(__NR_vgetcpu));
map_vsyscall();
#ifdef CONFIG_SYSCTL
register_sysctl_table(kernel_root_table2, 0);
register_sysctl_table(kernel_root_table2);
#endif
on_each_cpu(cpu_vsyscall_init, NULL, 0, 1);
hotcpu_notifier(cpu_vsyscall_notifier, 0);
Expand Down
2 changes: 1 addition & 1 deletion arch/x86_64/mm/init.c
Original file line number Diff line number Diff line change
Expand Up @@ -734,7 +734,7 @@ static ctl_table debug_root_table2[] = {

static __init int x8664_sysctl_init(void)
{
register_sysctl_table(debug_root_table2, 0);
register_sysctl_table(debug_root_table2);
return 0;
}
__initcall(x8664_sysctl_init);
Expand Down
2 changes: 1 addition & 1 deletion drivers/cdrom/cdrom.c
Original file line number Diff line number Diff line change
Expand Up @@ -3553,7 +3553,7 @@ static void cdrom_sysctl_register(void)
if (initialized == 1)
return;

cdrom_sysctl_header = register_sysctl_table(cdrom_root_table, 0);
cdrom_sysctl_header = register_sysctl_table(cdrom_root_table);

/* set the defaults */
cdrom_sysctl_settings.autoclose = autoclose;
Expand Down
2 changes: 1 addition & 1 deletion drivers/char/hpet.c
Original file line number Diff line number Diff line change
Expand Up @@ -1018,7 +1018,7 @@ static int __init hpet_init(void)
if (result < 0)
return -ENODEV;

sysctl_header = register_sysctl_table(dev_root, 0);
sysctl_header = register_sysctl_table(dev_root);

result = acpi_bus_register_driver(&hpet_acpi_driver);
if (result < 0) {
Expand Down
2 changes: 1 addition & 1 deletion drivers/char/ipmi/ipmi_poweroff.c
Original file line number Diff line number Diff line change
Expand Up @@ -686,7 +686,7 @@ static int ipmi_poweroff_init (void)
printk(KERN_INFO PFX "Power cycle is enabled.\n");

#ifdef CONFIG_PROC_FS
ipmi_table_header = register_sysctl_table(ipmi_root_table, 0);
ipmi_table_header = register_sysctl_table(ipmi_root_table);
if (!ipmi_table_header) {
printk(KERN_ERR PFX "Unable to register powercycle sysctl\n");
rv = -ENOMEM;
Expand Down
2 changes: 1 addition & 1 deletion drivers/char/rtc.c
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ static struct ctl_table_header *sysctl_header;

static int __init init_sysctl(void)
{
sysctl_header = register_sysctl_table(dev_root, 0);
sysctl_header = register_sysctl_table(dev_root);
return 0;
}

Expand Down
2 changes: 1 addition & 1 deletion drivers/macintosh/mac_hid.c
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ int __init mac_hid_init(void)
return err;

#if defined(CONFIG_SYSCTL)
mac_hid_sysctl_header = register_sysctl_table(mac_hid_root_dir, 0);
mac_hid_sysctl_header = register_sysctl_table(mac_hid_root_dir);
#endif /* CONFIG_SYSCTL */

return 0;
Expand Down
2 changes: 1 addition & 1 deletion drivers/md/md.c
Original file line number Diff line number Diff line change
Expand Up @@ -5581,7 +5581,7 @@ static int __init md_init(void)
md_probe, NULL, NULL);

register_reboot_notifier(&md_notifier);
raid_table_header = register_sysctl_table(raid_root_table, 0);
raid_table_header = register_sysctl_table(raid_root_table);

md_geninit();
return (0);
Expand Down
2 changes: 1 addition & 1 deletion drivers/net/wireless/arlan-proc.c
Original file line number Diff line number Diff line change
Expand Up @@ -1244,7 +1244,7 @@ int __init init_arlan_proc(void)
return 0;
for (i = 0; i < MAX_ARLANS && arlan_device[i]; i++)
arlan_table[i].ctl_name = i + 1;
arlan_device_sysctl_header = register_sysctl_table(arlan_root_table, 0);
arlan_device_sysctl_header = register_sysctl_table(arlan_root_table);
if (!arlan_device_sysctl_header)
return -1;

Expand Down
6 changes: 3 additions & 3 deletions drivers/parport/procfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -518,7 +518,7 @@ int parport_proc_register(struct parport *port)
t->parport_dir[0].child = t->port_dir;
t->dev_dir[0].child = t->parport_dir;

t->sysctl_header = register_sysctl_table(t->dev_dir, 0);
t->sysctl_header = register_sysctl_table(t->dev_dir);
if (t->sysctl_header == NULL) {
kfree(t);
t = NULL;
Expand Down Expand Up @@ -574,7 +574,7 @@ int parport_device_proc_register(struct pardevice *device)
t->device_dir[0].child = t->vars;
t->vars[0].data = &device->timeslice;

t->sysctl_header = register_sysctl_table(t->dev_dir, 0);
t->sysctl_header = register_sysctl_table(t->dev_dir);
if (t->sysctl_header == NULL) {
kfree(t);
t = NULL;
Expand All @@ -597,7 +597,7 @@ int parport_device_proc_unregister(struct pardevice *device)
static int __init parport_default_proc_register(void)
{
parport_default_sysctl_table.sysctl_header =
register_sysctl_table(parport_default_sysctl_table.dev_dir, 0);
register_sysctl_table(parport_default_sysctl_table.dev_dir);
return 0;
}

Expand Down
2 changes: 1 addition & 1 deletion drivers/scsi/scsi_sysctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ static struct ctl_table_header *scsi_table_header;

int __init scsi_init_sysctl(void)
{
scsi_table_header = register_sysctl_table(scsi_root_table, 0);
scsi_table_header = register_sysctl_table(scsi_root_table);
if (!scsi_table_header)
return -ENOMEM;
return 0;
Expand Down
2 changes: 1 addition & 1 deletion fs/coda/sysctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ void coda_sysctl_init(void)

#ifdef CONFIG_SYSCTL
if ( !fs_table_header )
fs_table_header = register_sysctl_table(fs_table, 0);
fs_table_header = register_sysctl_table(fs_table);
#endif
}

Expand Down
2 changes: 1 addition & 1 deletion fs/dquot.c
Original file line number Diff line number Diff line change
Expand Up @@ -1841,7 +1841,7 @@ static int __init dquot_init(void)

printk(KERN_NOTICE "VFS: Disk quotas %s\n", __DQUOT_VERSION__);

register_sysctl_table(sys_table, 0);
register_sysctl_table(sys_table);

dquot_cachep = kmem_cache_create("dquot",
sizeof(struct dquot), sizeof(unsigned long) * 4,
Expand Down
2 changes: 1 addition & 1 deletion fs/lockd/svc.c
Original file line number Diff line number Diff line change
Expand Up @@ -512,7 +512,7 @@ module_param(nsm_use_hostnames, bool, 0644);

static int __init init_nlm(void)
{
nlm_sysctl_table = register_sysctl_table(nlm_sysctl_root, 0);
nlm_sysctl_table = register_sysctl_table(nlm_sysctl_root);
return nlm_sysctl_table ? 0 : -ENOMEM;
}

Expand Down
2 changes: 1 addition & 1 deletion fs/nfs/sysctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ static ctl_table nfs_cb_sysctl_root[] = {

int nfs_register_sysctl(void)
{
nfs_callback_sysctl_table = register_sysctl_table(nfs_cb_sysctl_root, 0);
nfs_callback_sysctl_table = register_sysctl_table(nfs_cb_sysctl_root);
if (nfs_callback_sysctl_table == NULL)
return -ENOMEM;
return 0;
Expand Down
2 changes: 1 addition & 1 deletion fs/ntfs/sysctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ int ntfs_sysctl(int add)
{
if (add) {
BUG_ON(sysctls_root_table);
sysctls_root_table = register_sysctl_table(sysctls_root, 0);
sysctls_root_table = register_sysctl_table(sysctls_root);
if (!sysctls_root_table)
return -ENOMEM;
#ifdef CONFIG_PROC_FS
Expand Down
2 changes: 1 addition & 1 deletion fs/ocfs2/cluster/nodemanager.c
Original file line number Diff line number Diff line change
Expand Up @@ -922,7 +922,7 @@ static int __init init_o2nm(void)
o2hb_init();
o2net_init();

ocfs2_table_header = register_sysctl_table(ocfs2_root_table, 0);
ocfs2_table_header = register_sysctl_table(ocfs2_root_table);
if (!ocfs2_table_header) {
printk(KERN_ERR "nodemanager: unable to register sysctl\n");
ret = -ENOMEM; /* or something. */
Expand Down
2 changes: 1 addition & 1 deletion fs/xfs/linux-2.6/xfs_sysctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ static ctl_table xfs_root_table[] = {
void
xfs_sysctl_register(void)
{
xfs_table_header = register_sysctl_table(xfs_root_table, 0);
xfs_table_header = register_sysctl_table(xfs_root_table);
}

void
Expand Down
4 changes: 2 additions & 2 deletions include/linux/sysctl.h
Original file line number Diff line number Diff line change
Expand Up @@ -1035,8 +1035,8 @@ struct ctl_table_header
struct completion *unregistering;
};

struct ctl_table_header * register_sysctl_table(ctl_table * table,
int insert_at_head);
struct ctl_table_header * register_sysctl_table(ctl_table * table);

void unregister_sysctl_table(struct ctl_table_header * table);

#else /* __KERNEL__ */
Expand Down
2 changes: 1 addition & 1 deletion ipc/ipc_sysctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ static struct ctl_table ipc_root_table[] = {

static int __init ipc_sysctl_init(void)
{
register_sysctl_table(ipc_root_table, 0);
register_sysctl_table(ipc_root_table);
return 0;
}

Expand Down
2 changes: 1 addition & 1 deletion ipc/mqueue.c
Original file line number Diff line number Diff line change
Expand Up @@ -1255,7 +1255,7 @@ static int __init init_mqueue_fs(void)
return -ENOMEM;

/* ignore failues - they are not fatal */
mq_sysctl_table = register_sysctl_table(mq_sysctl_root, 0);
mq_sysctl_table = register_sysctl_table(mq_sysctl_root);

error = register_filesystem(&mqueue_fs_type);
if (error)
Expand Down
9 changes: 2 additions & 7 deletions kernel/sysctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -1244,7 +1244,6 @@ int do_sysctl_strategy (ctl_table *table,
/**
* register_sysctl_table - register a sysctl hierarchy
* @table: the top-level table structure
* @insert_at_head: whether the entry should be inserted in front or at the end
*
* Register a sysctl table hierarchy. @table should be a filled in ctl_table
* array. An entry with a ctl_name of 0 terminates the table.
Expand Down Expand Up @@ -1310,8 +1309,7 @@ int do_sysctl_strategy (ctl_table *table,
* This routine returns %NULL on a failure to register, and a pointer
* to the table header on success.
*/
struct ctl_table_header *register_sysctl_table(ctl_table * table,
int insert_at_head)
struct ctl_table_header *register_sysctl_table(ctl_table * table)
{
struct ctl_table_header *tmp;
tmp = kmalloc(sizeof(struct ctl_table_header), GFP_KERNEL);
Expand All @@ -1322,10 +1320,7 @@ struct ctl_table_header *register_sysctl_table(ctl_table * table,
tmp->used = 0;
tmp->unregistering = NULL;
spin_lock(&sysctl_lock);
if (insert_at_head)
list_add(&tmp->ctl_entry, &root_table_header.ctl_entry);
else
list_add_tail(&tmp->ctl_entry, &root_table_header.ctl_entry);
list_add_tail(&tmp->ctl_entry, &root_table_header.ctl_entry);
spin_unlock(&sysctl_lock);
#ifdef CONFIG_PROC_SYSCTL
register_proc_table(table, proc_sys_root, tmp);
Expand Down
2 changes: 1 addition & 1 deletion kernel/utsname_sysctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ static struct ctl_table uts_root_table[] = {

static int __init utsname_sysctl_init(void)
{
register_sysctl_table(uts_root_table, 0);
register_sysctl_table(uts_root_table);
return 0;
}

Expand Down
2 changes: 1 addition & 1 deletion net/appletalk/sysctl_net_atalk.c
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ static struct ctl_table_header *atalk_table_header;

void atalk_register_sysctl(void)
{
atalk_table_header = register_sysctl_table(atalk_root_table, 0);
atalk_table_header = register_sysctl_table(atalk_root_table);
}

void atalk_unregister_sysctl(void)
Expand Down
Loading

0 comments on commit 0b4d414

Please sign in to comment.