ee2f
![]() |
|
|
|
|
|||||||
| FreeBSD Development Kernel development, writing drivers, coding, and questions regarding FreeBSD internals. |
![]() |
|
|
Thread Tools | Display Modes |
|
#1
|
|||
|
|||
|
hi folks,
i coded a simple module, which shall read a configuration file residing in userland. now, here i am stuck first in a design question and secondly on "how to implement such". the module is intended to handle certain requests onto a permission configuration file, which i don't want and can put hardcoded into the code(the module shall on a configuration change not recompiled the whole time )first, and most, i wonder what would be the common/suggested way for a kernel module to get some kind of configuration(is this even intended?) . is it usual read it at runtime(after loaded, after refresh), is it more suggested to have a userland daemon which is communicating with the module or a possible device driver? now, secondly, in regard to the design question what would be the proper functions to do such in kernelland? i know a bit about the uio stuff for device drivers and copyin/copyout as well. regards, |
|
#2
|
|||
|
|||
|
You can set initial configuration via device.hints(9). And there are a lot of kernel modules reading sysctl's.
|
|
#3
|
|||
|
|||
|
It depends on e.g. how large and complicated the config file would be. I'd start with sysctl. Then you could just put the configuration variables into /etc/sysctl.conf; there is an rc script to set these values at system startup. If you want to be able to set configuration first and load the module later, you could implement them as tunables (see kenv(1)). There is an API for easily accessing both in the kernel.
|
|
#4
|
||||
|
||||
|
Quote:
Anything that can go in device.hints can also go into loader.conf. |
|
#5
|
|||
|
|||
|
hej guys,
first thank you for your input. wasn't a bit out of time. i decided to give it a first shot with sysctl and see how things are going and if the config gets not to complex. i'll be back with module or thread here in some days i guess ![]() till then, best regards |
|
#6
|
|||
|
|||
|
ok, i implemented some basic's but i am somehow stuck on the sysctl issues. i added a new branch with SYSCTL_ADD_NODE, i can add there strings and it is, working almost fine.
now i am looking for adding additional node to the already created node, to achieve this tree: Code:
application.node1 application.node1.family1 application.node1.family1.id=0 application.node1.family1.name=username application.node1.family2 application.node1.family2.id=1 application.node1.family1.name=anothername Code:
test2 = SYSCTL_ADD_NODE( NULL, SYSCTL_STATIC_CHILDREN(test1),OID_AUTO, "family", CTLFLAG_RW, 0, "test2"); Code:
tester.c:314: error: 'sysctl_test1_children' undeclared (first use in this function) i wonder as well how i can implement a good way of searching through the sysctl values on module side to decide what actions to take. is there some kind like LIST_FOREACH mechanism? additionally i figured after creating a node and not adding a string or integer results on my side with a kernel trap during kldload, is there a specifig reason for this? someone can point me to a paper/book/self explaining module code for SYSCTL topic? ![]() best regards, Last edited by eyebone; April 29th, 2010 at 21:36. |
|
#7
|
|||
|
|||
|
ok, i found a perfect example:
http://fxr.googlebit.com/source/shar...NETBSD-CURRENT it is from netbsd and serves to understand the basics of the usage
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| How to add source file infomation to kgdb for my kernel module | snaily | FreeBSD Development | 9 | February 7th, 2010 09:39 |
| Building kernel modules without kernel source code | holycow | General | 5 | April 2nd, 2009 09:18 |
| Reading currently running kernel configuration | pbd | General | 9 | March 5th, 2009 03:53 |
| Is the cciss kernel module available in the installation kernel & other general Q's | osx-addict | Installing & Upgrading | 2 | March 2nd, 2009 18:14 |
| Config File and WTMP | bamcis | General | 3 | February 28th, 2009 22:09 |