Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Adding a new system call in Linux kernel 3.3

I am very new to this kernel thing. What I want to do is just add a new system call to the kernel. I was following this guideline: http://hekimian-williams.com/?p=20.

The problem is there used to syscall_table_32.S file under arch/x86/kernel, but I cannot find the file for x86 systems in kernel version 3.3. Do I still need to edit the file and append one more line for the newly added system call? Or do I need to do something else to let the kernel know about my new system call? Any help will be appreciated. Thank you.

like image 871
NeoJi Avatar asked Feb 02 '23 06:02

NeoJi


2 Answers

I think in kernel 3.3 its shifted here

http://lxr.free-electrons.com/source/arch/x86/syscalls/

like image 100
Pavan Manjunath Avatar answered Feb 05 '23 09:02

Pavan Manjunath


How to add a new Linux kernel API in 3.3 version? -- for 64 bits OS

  • get kernel codes from www.kernel.org.

wget http://www.kernel.org/pub/linux/kernel/v3.0/linux-3.3.1.tar.bz2

  • Upzip it with command ‘tar xvfj XXX” to a folder For example : /root/kernel tar xvfj linux-3.3.1.tar.bz2

  • Edit file “/root/kernel/linux-3.3.1/arch/x86/syscalls/syscall_64.tbl” Add new line

312 64 husky1 sys_husky1

  • Eidt file “/root/kernel/linux-3.3.1/include/linux/syscalls.h” Add new function declaration

asmlinkage long sys_husky1(int fd);

before the line “#endif”

  • Add a new c file under “/root/kernel/linux-3.3.1/arch/x86/kernel” (I am using x86 CPU) Example :

  • Edit “/root/kernel/linux-3.3.1/arch/x86/kernel/Makefile” Add a new line “obj-y += husky.o”

  • goto /root/kernel/linux-3.3.1 folder and run command “make –j8”

like image 23
libo500k Avatar answered Feb 05 '23 09:02

libo500k