How to add a system call in Linux

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:
Here Insert Picture Description      I will extract the files to:
Here Insert Picture DescriptionAdd 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:
Here Insert Picture Descriptiondeclare function prototype system call
      (vim include / linux / syscalls.h) FIG:
Here Insert Picture Descriptiondefinition of system call functions to add
      (vim kernel / sys.c)
Here Insert Picture Descriptionabove 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.
Here Insert Picture DescriptionCompile: sudo make
Here Insert Picture Description due to the author's personal computer CPU and solid too ordinary, run ubuntu finally be completed after one hour. Figure:
Here Insert Picture DescriptionInstalling the kernel
    sudo make install
Here Insert Picture Descriptionto write the test program
Here Insert Picture DescriptionHere Insert Picture Description 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
Here Insert Picture Descriptiontest program
     to compile and run the test program: return 1
Here Insert Picture Description
    input: dmesg
Here Insert Picture Descriptiontest 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.

Guess you like

Origin blog.csdn.net/qq_38937025/article/details/91476033