sysconf - exposing constants to userspace
What is the preferred way to expose "constants" to userland? I quoty-finger "constants" because they may be defined as constants to any given kernel, they are not necessarily constant over time.
There are things which can be changed as constants which would currently require a libc recompile. For example NGROUPS_MAX :). Since it just got merged, anyone who wants to use it will have to recompile their libc to get the new value of NGROUPS_MAX.
I found an old old patch to do this via read-only sysctl() entries. Should I resurrect that patch? Or maybe just do a sys_sysconf() entry? Or should I just shut up and tell users to cope with recompiling libc?
Signature · 4 lines
Tim Hockin Sun Microsystems, Linux Software Engineering [email protected] All opinions are my own, not Sun's
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Quoted 4 lines · Tim Hockin
What is the preferred way to expose "constants" to userland? I quoty-finger "constants" because they may be defined as constants to any given kernel, they are not necessarily constant over time.
Quoted 8 lines
There are things which can be changed as constants which would currently require a libc recompile. For example
NGROUPS_MAX:). Since it just got merged, anyone who wants to use it will have to recompile their libc to get the new value ofNGROUPS_MAX.I found an old old patch to do this via read-only
sysctl()entries. Should I resurrect that patch? Or maybe just do asys_sysconf()entry? Or should I just shut up and tell users to cope with recompiling libc?
I think that making something in /sys would make the most sense, with one constant per file. We could dump the consts files to for example /sys/consts, or make a logical directory structure to make navigation easier.
Jeff.
- --
UNIX is user-friendly ... it's just selective about who it's friends are -----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (GNU/Linux)
iD8DBQFANSsEwFP0+seVj/4RAgiaAJ9ka5sUjXEE+xNazblPO73/ovnsrACgpZPX kGZV3gEplJpx24eL62AuQqA=
=3HMU
-----END PGP SIGNATURE-----
Quoted 7 lines · Jamie Lokier
Quoted 4 lines · Jeff Sipek
I think that making something in /sys would make the most sense, with one constant per file. We could dump the consts files to for example
/sys/consts, or make a logical directory structure to make navigation easier.Isn't that very similar to the
/proc/sys/kernelwe have now?
sysctls are all writable (unless I am missing something). A lot of these things are not really tunables.
Signature · 4 lines
Tim Hockin Sun Microsystems, Linux Software Engineering [email protected] All opinions are my own, not Sun's
Quoted 4 lines · Jeff Sipek
I think that making something in /sys would make the most sense, with one constant per file. We could dump the consts files to for example
/sys/consts, or make a logical directory structure to make navigation easier.
Isn't that very similar to the /proc/sys/kernel we have now?
-- Jamie
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Quoted 7 lines · Jamie Lokier
Quoted 4 lines · Jeff Sipek
I think that making something in /sys would make the most sense, with one constant per file. We could dump the consts files to for example
/sys/consts, or make a logical directory structure to make navigation easier.Isn't that very similar to the
/proc/sys/kernelwe have now?
If I understand the original post correctly, the numbers that we don't make available to userspace are compile time constants. For example, since I can't think of anything better, NR_CPUS. It is set during the config process, but one cannot read the number from userspace while running that kernel. I know that there are better examples, but I just can't think of any at the moment.
If I missed the point of the original post, please ignore me.
Jeff.
- --
Trust me, you don't want me doing _anything_ first thing in the morning.
- Linus Torvalds
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (GNU/Linux)
iD8DBQFANVUBwFP0+seVj/4RArdbAJ4tsq5cyDJ+058h1D6JDli1nsmP9ACeJnoN pxE9BuRBNND271SGp81SMHM=
=rmLE
-----END PGP SIGNATURE-----
Quoted 2 lines · * Tim Hockin ([email protected]) wrote:
sysctls are all writable (unless I am missing something). A lot of these things are not really tunables.
no, they actually have a mode. some are 0444.
thanks,
-chris
Signature · 1 line
Linux Security Modules http://lsm.immunix.org http://lsm.bkbits.net
Quoted 7 lines · Jeff Sipek
If I understand the original post correctly, the numbers that we don't make available to userspace are compile time constants. For example, since I can't think of anything better,
NR_CPUS. It is set during the config process, but one cannot read the number from userspace while running that kernel. I know that there are better examples, but I just can't think of any at the moment.If I missed the point of the original post, please ignore me.
No, you got it. BUt I was specifically thinking of POSIX sysconf stuff, like NGROUPS_MAX. See <linux/limits.h>.
Signature · 4 lines
Tim Hockin Sun Microsystems, Linux Software Engineering [email protected] All opinions are my own, not Sun's
Quoted 5 lines · * Jeff Sipek ([email protected]) wrote:
If I understand the original post correctly, the numbers that we don't make available to userspace are compile time constants. For example, since I can't think of anything better,
NR_CPUS. It is set during the config process, but one cannot read the number from userspace while running that kernel. I know that there are better examples, but I just can't think of any at the moment.
like /proc/sys/kernel/version? ;-)
later,
-chris
Signature · 1 line
Linux Security Modules http://lsm.immunix.org http://lsm.bkbits.net