sysctl read from kernel module?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello all,

Using 2.4.22, I have been working with some sysctl entries for controlling a
network-related module and have found the following two references very useful:

http://www.linuxjournal.com/article.php?sid=2365
http://www.geocities.com/chrootstrap/writing_sysctl_drivers_on_linux.html

I have created custom entries and can set/get them from userspace. However, I
can't figure out how to read the values I've set from inside a module. My
understanding is that I don't have access to the standard C library function
sysctl. The first article above from Alessandro Rubini is quite old and may be
out of date. In it, he says that if working from the kernel I should use the
_sysctl function wrapper. This appears to use a struct packed with the args
would normally go to the userspace equivalent function but frankly, I'm a
little out of my depth attempting to construct this alternative form of the arg
list - here are the prototypes for the functions:

Userspace:

int sysctl (int *name, int nlen, void *oldval, size_t *oldlenp,
void *newval, size_t newlen);

Args for _sysctl:

struct __sysctl_args {
    int *name;
    int nlen;
    void *oldval;
    size_t *oldlenp;
    void *newval;
    size_t newlen;
    unsigned long __unused[4];
};

In any case, I can't find the definition of the _sysctl function to include.
I've looked in the usual places i.e. Rubini's kernel and device driver books
from O'Reilly, Google Groups etc. and can't find anything except userspace
examples.

Can anyone provide any:
- solutions
- example code
- other sources of information?

Are there changes in the current kernel I should know about?

Many thanks for any help.
cam

__________________________________
Do you Yahoo!?
Yahoo! Finance: Get your refund fast by filing online.
http://taxes.yahoo.com/filing.html

--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/kernelnewbies/
FAQ:           http://kernelnewbies.org/faq/


[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux