Messages in this thread |  | | Date | Tue, 7 May 1996 11:03:22 +0300 (EET DST) | From | Linus Torvalds <> | Subject | Re: An idea: a database of modules settings |
| |
> On Sun, 5 May 1996, Eyal Lebedinsky wrote: > > > How about a standard API where a module can save/restore any number of > > settings between sessions. The module will simply call somethings like > > save_settings (int id, void *buffer, in size) > > where the id allows a module to save multiple buffers. The info will be > > saved and later the module (when loaded) can request the settings with a > > similar 'get_settings' call. > This looks like the right way to implement persistent data for drivers. > However I prefer using a string ad the 'id'. In this way less > administrative work is required to prevent conflicts between > drivers/modules.
No, this is not how to handle this. Saving persistent data in the kernel is a inherently broken idea - it should be done by "insmod" instead, and it should save the data in the filesystem. That way it will survive across a re-boot if the user so wishes etc etc. It's also the "right" way to do it anyway, because there simply is no sense in saving the data in the kernel when you can do it in user level.
Obviously "insmod" knows only about user-supplied parameters, and won't be able to save state that the driver itself has auto-detected etc, but that's a feature, not a bug. If it's been autodetected once, it's better to let it be autodetected in the future too..
I saw some patyches that did a "vmalloc()" and saved state in a kernel virtual area over multiple "insmod"s, and I sincerely hope I will never have to see that kind of thing ever again in my life. Ugh..
I don't know if insmod already handles things like this, but essentially it needs to do "pre-insmod" and "post-insmod" things anyway, where the "pre-insmod" thing can be looking up what addresses it should use (PnP, saved state, whatever), and "post-insmod" is things like setting up /dev and maybe adding routes for the new network interface it just inserted or whatever..
The kernel should not have to know about these things - it just inserts the damn thing, and policy decisions HAVE to be made in user space.
Linus
|  |