Linux Kernel Manual Pages
Having the ability to lookup how a kernel function works is very handy when writing your own device driver or any kernel module. Unfortunately you cannot just apt-get install kernel-manpages. Well wouldn’t that be nice! To get your kernel manual pages for a specific kernel you can download the kernel source and execute a few choice commands. Here is a short tutorial under Debian (and would probably work for most Linux distributions).
- Download your kernel version, in this case I grabbed version 2.6.32.3
- Untar the the document by: tar -xvf linux-2.6.32.3.tar.bz2
- Now move into the new linux-2.6.32.3 directory and type make mandocs. The system might prompt you to download missing packages to build the manuals, proceed to do so.
- After the documents have been made type make installmandocs, this will install the manual pages into /usr/local/man/man9/. This way you can now type man copy_to_user to see how to use the specified kernel function!
So, doing a man copy_to_user you will now get the output of:
NAME
copy_to_user – Copy a block of data into user space.
SYNOPSIS
unsigned long copy_to_user (void __user * to, const void * from, unsigned long n);
ARGUMENTS
to
Destination address, in user space.
from
Source address, in kernel space.
n
Number of bytes to copy.
CONTEXT
User context only. This function may sleep.
DESCRIPTION
Copy data from kernel space to user space.
Returns number of bytes that could not be copied. On success, this will be zero.
Erik is an avid Linux user and has experience with a wide variety of Linux/Unix based systems. In his spare time he likes writing software (C/C++/Perl/PHP/BASH/Python) and experimenting with different Linux distributions. He is starting to build a wide variety of articles Unix driven (what a surprise) that hope to inform those just getting into Linux on his website.