Writing a System Call
Hi everyone :D
I need to write a system call for the first time and it's proven to be pretty frustrating - I'm having trouble wrapping my head around it. But I figure I'll start off slow. Here is my declaration in sys.c:
The compiler returns:
SYSCALL_DEFINE1 (getprinfo, struct prinfo *info)
There are two arguments there. I can also see that info isn't being included in the compiler's output; it's saying that info is undeclared. Am I using SYSCALL_DEFINE1 incorrectly? Am I treating it too much like a user-space program?
/home/dtroberts/kernelSrc/kernel/sys.c:1816:1: error: macro "__SC_DECL1" requires 2 arguments, but only 1 given
Doing a quick trace through the /include/linux/syscalls.h file in the kernel source code implies to me that your arguments and their types should be separate:
Having never written a system call, I'm not entirely sure that this is accurate, but given that __SC_DECL1 is defined as:
SYSCALL_DEFINE1(getprinfo, struct prinfo *, info)
I suspect that this is true.
#define __SC_DECL1(t1, a1) t1 a1
Yep, you were right. Defining it as you said fixed my error. Thank you!
Originally Posted by Cabhan