module init data
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?
Regards,
moji
Quoted 8 lines · mojtaba
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.
Quoted 5 lines
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.
Signature · 1 line
Live like a child, think like the god.