سؤال

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...?

هل كانت مفيدة؟

المحلول

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.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top