LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Kernel (https://www.linuxquestions.org/questions/linux-kernel-70/)
-   -   Need help writing module to expose internal variable to /sys interface (https://www.linuxquestions.org/questions/linux-kernel-70/need-help-writing-module-to-expose-internal-variable-to-sys-interface-4175601393/)

otheus 03-09-2017 11:12 AM

Need help writing module to expose internal variable to /sys interface
 
I'm not sure if this can be done what I want to do.

I want to make readable/writable a particular variable within the Linux kernel. The variable is not statically declared and appears to have only one use: to be turned off.

It's defined in kernel/ntp.c as "no_sync_cmos_clock".

so first: am I going about this the wrong way? (ie, writing a module, reinventing the wheel)? Can I expose this variable in a private module?

dijetlo 03-11-2017 03:02 PM

I'd think long and hard on that one Otheus...

No Sync - Don't synchronize
CMOS clock - The hardware clock
In kernel/ntp - When using network time protocol....

Why would you want to expose it? It seems like it's a hardware detected value (i.e., a driver setting)? I mean I could be wrong, I'm not a kernel hacker by trade or anything but it doesn't seem like the kind of thing that would need to exposed, it's an expression of the capability of the underlying hardware, isn't it?.

I am interested in hearing your thoughts on this.

rigor 03-11-2017 11:20 PM

otheus,

If you are using "RHEL AS 4" as seems to be suggested by the info. associated with your post, then if I'm thinking correctly, that RHEL AS version is using a kernel that is rather old.

If that's your situation, then AFAIK, no_sync_cmos_clock was removed from the standard kernel not too long after the version of the kernel you are using, and it doesn't appear to be in the recent kernels.

So, unless Red Hat is maintaining that variable and the associated code themselves, or you wish to do so, then if you have any interest in updating to a newer version of the OS or kernel in the future, you might want to think about how you are going to maintain the code you're thinking of writing, as well as the code you'll need to write to implement that variable in the newer kernels.

Also, regardless of what kernel version you'll use, how you might need to expose that variable, might depend on what you wish to do with the interface to the point where the variable is exposed.

HTH.


All times are GMT -5. The time now is 10:57 PM.