LKM can create dynamically entries inside /proc/sys
, but sysctl
(not the Linux command but C's sysctl
) accepts as first argument an array of ints with predefined values representing entries inside /proc/sys
. My question is: can I read a dynamically created entry with sysctl
or do I need to use fopen
, read
, etc...?
Asked
Active
Viewed 735 times
0

alexandernst
- 14,352
- 22
- 97
- 197
1 Answers
1
You need to use the file system interface: fopen
, fread
, etc (or open
, read
, if you prefer).
And about the C function called sysctl
, don't use it:
Use of this system call has long been discouraged, and it is so unloved that it is likely to disappear in a future kernel version. Since Linux 2.6.24, uses of this system call result in warnings in the kernel log. Remove it from your programs now; use the
/proc/sys
interface instead.

Joni
- 108,737
- 14
- 143
- 193
-
Also, most of the pseudo-files in `/proc` are not seekable and should be read sequentially. – Basile Starynkevitch Oct 06 '13 at 12:36