How to add a system call in Linux
Download kernel source code
can be downloaded on github or https://www.kernel.org/. I downloaded the linux-4.4.4.tar.xz
download link: https://cdn.kernel.org/pub/linux/kernel/v4.x/linux-4.4.4.tar.xz
Decompressed
I've extraction is completed, it does not demonstrate the decompression process:
I will extract the files to:
Add system calls
into the decompression of Linux-4.4.4 folder: (vim ./arch/x86/entry/syscalls/syscall_64.tbl(32 bit systems syscall_32.tbl)) in FIG., added at the end:
declare function prototype system call
(vim include / linux / syscalls.h) FIG:
definition of system call functions to add
(vim kernel / sys.c)
above step substantially completed the preparatory steps of
Compile: (The following are also the focus of a key to the success of)
1.sudo the make menuconfig directly select save, then exit to generate a .config
2. Compile the make sudo start, I quad-core four threads, running in a virtual machine environment, large greatly reduced performance, running nearly 40 minutes
3. sudo make modules_install mounting module
4. sudo make install installation kernel
sudo make menuconfig pop up: the keyboard to move the cursor to the save options, generating .config, move the cursor to the Exit , select Exit.
Compile: sudo make
due to the author's personal computer CPU and solid too ordinary, run ubuntu finally be completed after one hour. Figure:
Installing the kernel
sudo make install
to write the test program
so far, test programming is completed.
Restart ubuntu (using the release of ubuntu 16.04), boot the system into clicking delete button on the keyboard, select Advanced Options, select we compiled kernel, wait for boot.
Use the command
uname -r to see the current version of the kernel: the kernel successfully selected
test program
to compile and run the test program: return 1
input: dmesg
test was successful.
Copyright Notice
1. The above experiment after I tested real and effective, but does not ensure that all feasible, resulting in losses to others. The damage has nothing to do with himself.
2. The above content by individuals without permission is not allowed to give any profit-making use, only learning to use.