You are not logged in.
hi there,
I'm trying to add a new system call to the kernel but all I found seems regarding old kernel versions.
I found only a posts that says to modify the file: arch/x86/syscalls/syscall_32.tbl (adding an entry for the syscall), then add the real code of the syscall to the file fs/open.c;
I wanted to do something like this:
http://appusajeev.wordpress.com/2010/11 … el-2-6-35/
and then use makepkg to compile the kernel.
any suggestion??
Last edited by alwaysanoob (2012-07-17 15:18:38)
Offline
make a patch (or several) to patch the kernel, then apply that patch in the PKGBUILD. You could look at the PKGBUILd of the linux package to get an idea of it
Best Testing Repo Warning: [testing] means it can eat you hamster, catch fire and you should keep it away from children. And I'm serious here, it's not an April 1st joke.
Offline
moving to kernel & hardware section..
Offline
Alwaysanoob, I believe moderators can move threads. You can request that they do so, but otherwise, please do not cross post.
"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman
Offline
ok, sorry for that
I was dubious about the right section to put the thread!
Offline
Okay, moving from Creating & Modifying Packages to Kernel & Hardware.
I have deleted your other thread. Good luck!
ok, sorry for that
I was dubious about the right section to put the thread!
It could go in either, that is assuming it's more about modifying the kernel than making a PKGBUILD.
aur S & M :: forum rules :: Community Ethos
Resources for Women, POC, LGBT*, and allies
Offline
yes it is, but when you finish to modify the kernel you use makepkg to compile, and I'd also like to know about some tricks to make the compilation faster!
Offline
new day = new discussion : )
how do I modify the kernel 3.4.4 in order to add a new system call, the question are:
where is the system call table?
if I insert the system call code in a directory (for example: src/new_syscall/, what about the Makefile inside that directory and the main PKGBUILD?
inserting a new entry in the system call table and writing the system call code are enough?
which are differences between x86 and x86_64?
Offline
for anyone who cares:
I have compiled and runned the custom kernel with a new dummy syscall
1. https://wiki.archlinux.org/index.php/Ke … ild_System
this contains main steps needed for kernel compilation with ABS
2. create a testing folder in src root: src/linux-3.4/testing/
put inside this folder:
- a file that contains syscall code: strcpy.c
#include <linux/linkage.h>
#include <linux/kernel.h>
asmlinkage long sys_strcpy(char *dest, char *src)
{
int i=0;
while(src[i]!=0) {
dest[i]=src[i++];
}
dest[i]=0;
printk("<1>done it!");
return 1;
}
- and the Makefile that contains just the following line:
obj-y:=strcpy.o
3. add an entry to the syscall table and the prototype of the function:
- edit the file src/linux-3.4/arch/x86/syscalls/syscall_32.tbl by adding this line to the entry 223 that is free
223 i386 strcpy sys_strcpy
- edit the file src/linux-3.4/include/linux/syscalls.h by adding the prototype of the function
asmlinkage long sys_strcpy(char *dest, char *src);
4. edit the main Makefile in the src root (src/linux-3.4/Makefile) by adding the testing folder created before, as follow:
core-y += kernel/ mm/ fs/ ipc/ security/ crypto/ block/ testing/
You have done!!
Compile the kernel and install the package as explained in #1.
Run the custom kernel and write a simple program like this to test the strcpy that's now a syscall (you are not including string.h in order to use strcpy):
#include <stdio.h>
int main(int argc, char *argv){
char *src="testing the syscall";
char dest[40];
syscall(223,dest,src);
printf("copied string:%s\n",dest);
}
Note that the number of the system call is the same defined before; in order to read the message written by the printk function, exec the command dmesg.
Edit the file /etc/makepkg.conf if you want to use all your cores during compilation phase:
#-- Make Flags: change this for DistCC/SMP systems
#MAKEFLAGS="-j2"
2 is for a single core, add 1 for any other core you are going to use.
You can use makepkg -e if you want to compile faster, but remember to comment patches in the PKGBUILD before doing this.
BYE
Last edited by alwaysanoob (2012-07-17 21:10:00)
Offline