Re: [PATCH/RFC] Deprecate sysctl(2), add sysctl_name

From: Andi Kleen (ak@suse.de)
Date: Fri Jul 11 2003 - 04:16:30 EST


On Thu, Jul 10, 2003 at 07:35:22PM -0700, Linus Torvalds wrote:
>
> On Fri, 11 Jul 2003, Andi Kleen wrote:
> >
> > This patch deprecates sysctl(2) by adding a printk to it. There is one
> > important user of it - glibc checks kernel.version in the startup code -
> > which is still handled without message. This needs to be still handled,
> > but the hope is that there are no other users of the numerical interface.
>
> I'd prefer to first _only_ deprecate it, and if somebody really really
> decides that they want another interface than /proc too, we can re-visit
> the thing then.

Ok fine for me. Here is a new patch that only deprecates.

> I doubt there is any real reason to not just use the /proc interface, and
> I dislike pre-emptive engineering.

I don't feel particularly strongly about the sysctl_name thing, if you
think it's not necessary great.

-Andi

-------------

Deprecate numerical sysctl namespace. The only exception is kernel/version,
which is widely used in glibc. The new recommended interface is /proc/sys

--- linux-2.5/include/linux/sysctl.h 2003-06-06 17:55:40.000000000 +0200
+++ linux-2.5-amd64/include/linux/sysctl.h 2003-07-09 23:15:45.000000000 +0200
@@ -6,16 +6,10 @@
  ****************************************************************
  ****************************************************************
  **
- ** WARNING:
  ** The values in this file are exported to user space via
- ** the sysctl() binary interface. Do *NOT* change the
- ** numbering of any existing values here, and do not change
- ** any numbers within any one set of values. If you have
- ** to redefine an existing interface, use a new number for it.
- ** The kernel will then return ENOTDIR to any application using
- ** the old binary interface.
- **
- ** --sct
+ ** the sysctl() binary interface. However this interface
+ ** is unstable and deprecated and will be removed in the future.
+ ** For a stable interface use /proc/sys.
  **
  ****************************************************************
  ****************************************************************
--- linux-2.5/kernel/sysctl.c 2003-07-04 23:52:20.000000000 +0200
+++ linux-2.5-amd64/kernel/sysctl.c 2003-07-11 03:25:18.000000000 +0200
@@ -823,7 +838,16 @@
 
         if (copy_from_user(&tmp, args, sizeof(tmp)))
                 return -EFAULT;
-
+
+ if (tmp.nlen != 2 || tmp.name[0] != CTL_KERN ||
+ tmp.name[1] != KERN_VERSION) {
+ int i;
+ printk(KERN_INFO "%s: numerical sysctl ", current->comm);
+ for (i = 0; i < tmp.nlen; i++)
+ printk("%d ", tmp.name[i]);
+ printk("is obsolete.\n");
+ }
+
         lock_kernel();
         error = do_sysctl(tmp.name, tmp.nlen, tmp.oldval, tmp.oldlenp,
                           tmp.newval, tmp.newlen);
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Tue Jul 15 2003 - 22:00:38 EST