# Where in kernel source "module load procedure"?



## str1ke (Aug 5, 2010)

Hello.
I want try to do "signs" for kernel modules (task in university :stud ). It will be very simple. For example we have file with list of kernel modules and it`s signs:

```
module_name_1 0
module_name_2 1
module_name_3 0
...
```
So, if "sign" = 1, then accept module load, if "sign" = 0 - reject, if no module in list - reject too.

So, the question is where in kernel source i can insert such thing?
P.S. Sorry for bad English


----------



## trasz@ (Aug 5, 2010)

See sys/kern/kern_linker.c (search for kldload(), this is the syscall handler), possibly also in sys/kern/kern_module.c.


----------



## str1ke (Sep 3, 2010)

*thanks*

thank you, this is what i was looking for. 
procedure is "kern_kldload".
I added printf("%s", file) and it worked good.
Now i want to print kernel name in file. I tried to add

```
FILE *out_file;
fopen(.....
```
And there is no such functions, how can add needed for me libraries(headers) to /usr/src/sys/kern/kern_linker.c. For example, library with file manipulation.
Thanks for help!


----------



## SirDice (Sep 3, 2010)

You cannot use external libraries inside the kernel.


----------



## str1ke (Sep 6, 2010)

So, how can read file content (for example /boot/signs.txt) from /usr/src/sys/kern/kern_linker.c?


----------



## trasz@ (Sep 6, 2010)

Maybe you could load the contents into the kernel from the userland, via sysctl or device file?  Opening files from inside the kernel is generally discouraged.


----------

