Linux OS system analysis (4)-kernel update and System Call Addition

Source: Internet
Author: User

Environment: Ubuntu 13.04

Student ID: SA * 310

Update Kernel

The kernel version of the directly installed system is generally not the latest.

uname -a

Command to view the kernel version number, for example, my is:

Next, manually update the kernel to the latest stable version.

1. Get source code

Go to and download the latest kernel source code,

The latest stable version is 3.9.4.

Decompress the downloaded package to the/usr/src folder.

sudo tar -xvf linux-3.9.4.tar.xz -C /usr/src/

2. Configure the kernel

Copy the original configuration file

cp /usr/src/linux-headers-2.6.32-27-generic/.config .config

First configure, enter the/usr/src // linux-3.9.4 folder, and execute

 make menuconfig


* ** Unable to find the ncurses libraries or
* ** Required header files.

The ncurses library is missing (a function library for managing the display of applications on character terminals:

sudo apt-get install ncurses-dev

Execute make menuconfig again

Select load, OK, and save.

3. Compile and install

Terminal execution:

Make bzimage # compile kernel make modules # compile the module make modules_install # first install the module make install # Install the kernel

The Compilation Time is determined by the machine performance.

After make install, grub has been automatically updated and you do not need to manually set the boot guide.

Restart and enter ubuntu. The first loading after the update will be slow.

Check the kernel version again and run it on the terminal.

uname -a

Add system call

The system call principle is as follows:

The three files in the source code directory that contain the kernel are:

/Kernel/sys. C // define system call

/ARCH/x86/syscils/syscall_32.tbl // set the system call number

/Include/Linux/syscils. h // System Call header file

The following is a simple system call.

1) Implementation of the System Call function.

Add the following code at the end of/kernel/sys. C:

asmlinkage int sys_callquansilang(int num){printk("Hi,I'm Quansilang. My student No. is sa*****310!");return 1;}

2) set the system call number

Edit the ARCH/x86/syscils/syscall_32.tbl file and find that the system has been called by the 350 definition numbers. Draw the gourd doll based on the gourd image and add your own system call at the end:

351 i386callquansilangsys_callquansilang

Be sure to correspond to the previously defined function.

3) Add the system call declaration to the header file.

Open/include/Linux/syscils. H, and add

asmlinkage int sys_callquansilang(int num);

4) recompile and install the kernel.

Sudo make mrproper # Clear the long-time compilation file sudo make # compile


Make modules_install # first install the module make install # Install the kernel

Restart the system.

5) test

Create a main. c

#include <unistd.h>#include <stdio.h>int main(){syscall(351,1);return 1;}

Compile and run, and then use

sudo dmesg -c

View the system call log (there will be a little delay in writing the system log ).


Add a system call to Linux kernel comparison between old and new kernels-

Ubuntu 12.10x64 new kernel compilation + System Call method-

Linux add kernel system call Report-

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.