Reputation: 3
In the 3.14 linux kernel there is the following macro :
#define SYSCALL_DEFINEx(x, sname, ...)
It's located in include/linux/syscalls.h.
I added a syscall in the source, I compiled it and I made a little program using the the syscall. It seems to works because my syscall have been called and printed a message.
But I didn't use the macro. I read things about it. I understood that this macro is for the arguments. But I don't understand when we have to use it because I made a "grep" and it seems that most of the syscalls which take parameters don't use it.
Do I have to use it? Why?
And I have the same probleme for others macro in the same file (SYSCALL_METADATA(sname, nb, ...), SYSCALL_TRACE_ENTER_EVENT(sname), etc). Do I have to use them all even if my syscall works?
I'm afraid to miss something if I don't use these macro and I can't find enough informations about it :/
Thanks!
Upvotes: 0
Views: 3391
Reputation: 2913
You should read Anatomy of a system call, part1 and part 2.
The SYSCALL_DEFINEx
macro shouldn't be used directly, but rather SYSCALL_DEFINE0
, SYSCALL_DEFINE1
, SYSCALL_DEFINE2
, etc. depending on the number of parameters your syscall takes.
This is the normal way to define syscalls in Linux. The purpose of the macros is to ensure that the appropriate compiler pragmas are applied to the function -- the standard function prologue and calling conventions don't apply to syscalls.
Depending on the kernel's config, rather than your personal preferences, the other pieces of code you see in the syscall macros get included or not. You can see that the whole SYSCALL_METADATA
code only gets included if CONFIG_FTRACE_SYSCALLS
is set.
Upvotes: 4