Search code examples
freebsd

freebsd add custom syscall by compiling the kernel?


for school work I have to add custom helloworld syscall to freebsd. I used following link as my guide: http://members.tripod.com/s_mathur/bsdhowto.html OK! In step two I got problem: root has not permission to run it so I used: "make sysent" instead. seems ok. Step 4 says: 4. Modify the Makefile to include sys_hello.c,etc and recompile the kernel.!!! Which makefile? and how to compile it and how call syscall hello? tnx in advance


Solution

  • If sys_hello.c contains your syscall implementation - and it's in sys/kern/sys_hello.c - then add this file to conf/files. Search for eg. "kern_fork.c" there and add sys_hello.c in a similar way. Afterwards, rebuild and reinstall kernel and world (make buildkernel buildworld installkernel installworld); world rebuild is neccessary to get the userspace part into libc.so. As for calling - well, call it like you would call another syscall. You will need to add the syscall declaration somewhere.