1

I am about to write my first kernel module for Linux ubuntu 3.8.0-29-generic

I do not have man 9 section for kernel functions (e.g. kmalloc, kfree...) Neither can I see some function definitions in /usr/include, but rather in /usr/src/linux-headers-3.2.0-53/include/linux. How do I include headers in my code in this case?

I suspect there might be something like apt-get install kernel-devel that would solve all these issues at once, but I can't find one.

Also a link to a good introduction to kernel module writing would be much appreciated. Thanks.

4

1 Answer 1

1

If you want to use kernel version 3.8.0, why do you have the headers of 3.2.0? You can download an extra source tree with the 3.8.0 and compile a new kernel without replacing the existing 3.2.0.

any way, lets work on the existing 3.2.0.

  • First, make sure the kernel the system is running is the same version as the headers directory you've mentioned.

    Check your system kernel version using:

    $ uname -r

    And see that you get 3.2.0. This means that when you include (#include) kernel header files in your program, they will be the ones in /usr/src/linux-headers-3.2.0-53/include/linux.

  • Second, installing man section 9: For that you will need to download the kernel source code. Choose the version you want from https://www.kernel.org/ and download it to your home directory. In that source directory execute:

    $ sudo apt-get install xmlto

    $ make mandocs

    $ sudo make installmandocs

Sign up to request clarification or add additional context in comments.

3 Comments

kernel.org doesn't have my version (3.13.0-24). is there a way to do that with apt-get source?
I think you can download it from here packages.ubuntu.com/trusty/linux-source-3.13.0
it happened be much easier with apt-get (wiki.ubuntu.com/Kernel/BuildYourOwnKernel). And I will accept your answer as it helped me with those mandocs makes :-)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.