Total Pageviews
Friday, March 30, 2012
Test Cases for read system call
Friday, March 23, 2012
Adding System Call
Hi
These are the steps to add system call to the linux kernel 2.6.39.4
Download source code http://kernel.org/pub/linux/kernel/v2.6/linux-2.6.39.4.tar.bz2
Open file linux-2.6.39/arch/x86/kernel/syscall_table_32.S
add line
.long sys_add2
Open linux-2.6.39/arch/x86/include/asm/unistd_32.h
After Line
#define __NR_syncfs 344
Add line
#define __NR_add2 345
and also change NR_syscalls to
#define NR_syscalls 346
Now edit linux-2.6.39/arch/x86/include/asm/unistd_64.hFind Lines#define __NR_syncfs 306__SYSCALL(__NR_syncfs, sys_syncfs)Add Line#define __NR_add2 307__SYSCALL(__NR_add2,sys_add2)
open filelinux-2.6.39/include/linux/syscalls.hbefore #endif add
asmlinkagelongsys_add2(inti,intj);
Now create add2.clinux-2.6.39/kernel/add2.c#includeasmlinkage long sys_add2(int i,int j)
{return i+j;}Now open the Makefile in this folder(linux-2.6.39/kernel/Makefile) and find outobj-y += groups.oAdd a new line before this line :obj-y += add2.oNow its Time to compile kernelGo to linux-2.6.39/$makeStart compiling to kernel modules:
$make modules
Install kernel modulessu -$make modules_installIt is time to install kernel itself$make install$update-grub