lkml.org 
[lkml]   [1998]   [Jan]   [5]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
Subjectsysctl() considered harmful
A moment ago I wrote about the difference in result
between using /proc and sysctl(). That seemed to
indicate that nobody is using sysctl().
Now that I look a bit more, it is good that nobody uses it,
because it does random things.

The names that sysctl() uses are arrays of integers.
But the kernel variable addressed by such an array
depends on the kernel version. Yucch!

So, any code that uses sysctl() instead of procfs
must call uname() or so first, and have a built-in
database with what integer names the various variables
have in various kernels. And such a program will do
random things next year when some kernel hacker has
changed the numbers again.
(And changing them was made easier by using enum's in
2.1.* instead of the #define's of 2.0.* - it seems so
easy to insert something in a list.)

Maybe we should throw out sysctl(), before some author
thinks that she can use it.

Andries

Ref: compare sysctl.h in 2.0.33 and 2.1.77.
E.g., what value has KERN_SECURELVL? and NET_IPV4_ARP_TIMEOUT?
What variable is accessed on one system by a program
compiled on the other?

\
 
 \ /
  Last update: 2005-03-22 13:41    [W:0.571 / U:0.052 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site