Re: module init data

From: AmÃrico Wang
Date: Tue Jan 19 2010 - 09:17:17 EST

On Mon, Jan 18, 2010 at 03:01:56PM +0100, mojtaba wrote:
>Hi there,
>I have a kernel modules which needs to maintain a table of some
>information. the data in the table can be changed during the system
>run and some new raws might be added to the table. The table also
>must be initialized at the system startup with the values from the
>previous run.
>As using files is not good in kernel mode, how can I load the data at
>the startup and store them as they changed? These information are
>device related. Can I use sysfs for this issue? Is there any tutorial
>on how to do that?

You can't use sysfs here, since it also stays in memory.

What you want is an interface to read and write those information
to/from the userspace, you can take iptables-save and iptables-restore
as an example.

One design of such interface would be passing a data structure which
contains all the table information from user space to kernel space
via syscall. Thus a user-space program will need to parse the data in
a file into that data structure and then do that syscall.

With this interface on hand, you can write an init-script to load the
table info during boot and to save the info during shutdown.

Live like a child, think like the god.

To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at
Please read the FAQ at