Re: Mapping Files in kernel space

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

 



Hi!

Welcome to the list. Although I think the previous reply was a bit
abrupt, it's generally considered best practice not to send HTML mail
on technical lists - now if I could just convince everyone else never
to send me HTML mail then I could actually have it all automatically
junked (of course in reality you can't ignore this stuff in business)
:-)

On Tue, 29 Mar 2005 20:33:06 -0800 (PST), Anup J <pj_anup78@xxxxxxxxxxx> wrote:

> I wanted to permanently store some values in the file
> and read it from the module so that the values are not
> lost even after reboot.

Yes. But you don't want to read it from the module as that's not how
we do things on Linux. What you want to do is have a userspace program
populate some kernel data structures through a /proc interface -
investigate initscripts in /etc/init.d, for example the mixer scripts
which save and restore your sound settings across reboots (just a
random example). These don't directly access a kernel interface, but
call a userspace helper that does (although don't do it using ioctls!
:P ) - so, you do this:

    * system boots
    * /etc/init.d/my_driver reads in settings from
/etc/my_driver/foo.bar and calls my_helper
    * my_helper shoves these in to the appropriate interface in
/proc/, maybe just using cat.
    * on shutdown, the same initscript runs as a kill script and saves
parameters.

> Is there anyother method to workaround this?.

The above method is the only real way you want to do this, in general.

> But the file size is big.

You can always mmap a device file in a userspace helper and shove
things in to the kernel this way - yes, there are several context
switches and the whole process is not terribly efficient *but* you
only want to run this twice for each time the system runs, so don't
care. Be aware that the system might not get shutdown nicely if the
power fails though.

Jon.

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