usleep function makes kernel module doesn't load. Why?

I an writing kernel module using this article:

http://www.freesoftwaremagazine.com/articles/writing_a_kernel_module_for_freebsd

I have actually two problems. When I try to include file #include <stdio.h> or any other like unistd e.t.r. It doesn't see them and tells that there are no such file. But it is a lie.

And second problem is that when I try to use in my kernel code function usleep it compiles well but i just cant load this module. It tells that file is not found. But its not true.

What should I change comparing to the info indicated in the article to use function like sleep f.ex. (for now it tells me that this function is unknown). And why it doesn't sees standard include files?

Thanks in advance.
 
In the kernel you can't use anything depending on libc, as it belongs to userland. After getting that 'file not found' check dmesg, linker puts diagnostic information there.
 
mjguzik said:
In the kernel you can't use anything depending on libc, as it belongs to userland. After getting that 'file not found' check dmesg, linker puts diagnostic information there.

Thanks great for your answer. Could you please then indicate me where can I find the list of functions that I can use in my kernel?
 
9th section of manpages, various headers from /usr/include/sys, reading the code to know how to do things. Also note that some useful functions like strlcat, strclcpy and so on are available in libkern library.
 
Code:
> man libkern
No manual entry for libkern
> man kern
No manual entry for kern

I hate it when that happens.
 
vyrtosu said:
And second problem is that when I try to use in my kernel code function usleep it compiles well but i just cant load this module. It tells that file is not found. But its not true.

# sysctl kern.module_path
kern.module_path: /boot/kernel;/boot/modules
 
That's not the case. If the kernel linker fails to resolve a symbol, appropriate message is printed to the console (something like "link_elf: symbol foo undefined") and errno is set to ENOENT, thus 'No such file or directory'.
 
Back
Top