Presentation is loading. Please wait.

Presentation is loading. Please wait.

Build A New Kernel and Add New System Calls in A Linux OS

Similar presentations


Presentation on theme: "Build A New Kernel and Add New System Calls in A Linux OS"— Presentation transcript:

1 Build A New Kernel and Add New System Calls in A Linux OS
C.L. Chou

2 Goals Learn how to build a new Linux kernel
Learn how to add new system calls

3 Build A New Linux Kernel

4 Reference Refer to relative documents on Internet
Use “how to build a linux kernel” as key words for search engine. E.g.

5 Note for Kernel Configuration
File system support RAM disk support may need to be checked when configuring the kernel. Device Drivers  Block devices  RAM disk support Network devices’ drivers have to be checked according to what kinds of network devices equipped on your PC.

6 Note for Kernel Compilation and Installation
Basic installation steps: %make xconfig/menuconfig %make dep %make clean %make bzImage %make modules %make modules_install %make install Automatically copy kernel image, copy system.map, create initial ramdisk, modify grub.conf, etc.

7 Add New System Calls

8 Reference Refer to relative documents on Internet
Use “how to add a system call” as key words for search engine. E.g.

9 Added or Modified Kernel Files
The version of example kernel is Files added or modified in the kernel: arch/i386/kernel/syscall_table.S (split from entry.S) include/asm/unistd.h include/linux/myservice.h include/net/myvariable.h net/ipv4/myservice.c init/main.c net/ipv4/tcp.c

10 Functionalities of added system calls
mysetflag() Turn on/off a kernel flag to start/stop counting the number of invoking tcp_sendmsg() in the kernel. mygetdata() Obtain the number of invoking tcp_sendmsg() recorded in the kernel.

11 arch/i386/kernel/syscall_table.S
Modified file Search key words: sys_mysetflag sys_mygetdata

12 include/asm/unistd.h Modified file Search key words: mysetflag
mygetdata #define NR_syscalls 313 313 is the total number of system calls.

13 include/linux/myservice.h
Added file The header file of net/ipv4/myservice.c

14 include/net/myvariable.h
Added file Declaration of two global variables and one data structure which are used in kernel.

15 net/ipv4/myservice.c Added file
Define two system call functions and one initialization function. sys_mysetflag() sys_mygetdata() myvariable_init()

16 init/main.c Modified file Search key word: myvariable_init (twice)

17 net/ipv4/tcp.c Modified file Search key words: myflag (twice)
tcp_sendmsg_call_count (twice)

18 User-level Example Program Files
myservice_user.h myservice_user.c Compiling myservice_user.c gcc –o myservice_user myservice_user.c

19 Demo Date: 4/24 (Mon.), 4/25(Tues.) at EC215 Steps:
Run the user-level program. Run any application that creates a TCP connection to send data packets. ssh ftp http

20 Downloading FTP Site IP: 140.113.214.77 Port: 21 Login: homework
Password: homework Files: Build A New Kernel and Add New System Calls.ptt linux tar.gz myservice_user.tar.gz


Download ppt "Build A New Kernel and Add New System Calls in A Linux OS"

Similar presentations


Ads by Google