Where to call my init() from (without LKM)?
Hi, For a small side-project I decided to make some changes directly to the kernel code, so that it offers some extra functionality I need. I have not done this before in such capacity and only put together some modules here and there in the past. Since now I'm not creating a module, instead I'm hacking the kernel directly, I have some questions: Most of my code is implemented in a new file I created under /kernel/myfile.c and added in the main Makefile (other parts of the code are spread around the existing code as edits). Question A: Is that a good idea? Alternatives? When developing modules, you have the module_init where you declare a function to run when the module inits and set up everything. In my code, I have a similar init function, that basically sets up some procfs endpoints so that users can configure parts of my system with boolean options (enable/disable functionality). Question B: Where is the best place to I call this init function from? Question C: Is using procfs the best option for setting up config options for my system? Best, George
On Sun, 04 Aug 2013 10:40:42 +0100, George White said:
Most of my code is implemented in a new file I created under /kernel/ myfile.c and added in the main Makefile (other parts of the code are spread around the existing code as edits).
Question A: Is that a good idea? Alternatives?
Convince us it should be under kernel/ and not elsewhere in the tree.
Question B: Where is the best place to I call this init function from?
There's a nice 'initcall' infrastructure which will get your code called during system boot. You even have some control over *when* it gets called (early, or with other devices, or other kernel code, or late).
Question C: Is using procfs the best option for setting up config options
Probably not. sysfs exists for a reason. Also, depending on what the code does and when it needs to initialize, procfs may not be an option (if you have to touch the vallue before userspace gets cranking, it won't work and you need to use a kernel commandline option).
participants (2)
-
George White -
Valdis.Kletnieks@vt.edu