For a college assignment we have to add a system call to the Linux kernel. I have “Hello, World” done no problem. In terms of adding a more complicated call, I know (or at least think) I can’t use C functions like malloc, but I’m wondering can I use syscall() to use other system calls?
Share
The kernel has its own specific calls for pretty much everything. You don’t have access to system calls or
<sys/xxxx.h>header files.For your exmaple, yes, you can’t use
malloc()but you can usekmalloc()In older versions of the kernel (2.4) you could use
syscall()via:syscallN()macros. I’m pretty sure that’s been removed.In general
syscalls()from the kernel is not a good idea. Really system calls are just a way of user space going into the kernel to do something, so if you’re already in the kernel there should be a better way to do what you’re trying to do.