Linux - KernelThis forum is for all discussion relating to the Linux kernel.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Compiling this codes, error was occured like this.
iphash.c:37: error: expected declaration specifiers or '...' before 'insert_ipha sh_entry'
iphash.c:37: error: expected declaration specifiers or '...' before 'category'
iphash.c:37: error: expected declaration specifiers or '...' before 'ip'
iphash.c:37: error: expected declaration specifiers or '...' before 'action'
iphash.c:37: warning: data definition has no type or storage class
iphash.c:37: warning: type defaults to 'int' in declaration of '_syscall3'
I found the reason.
unistd.h which is in my system doesn't have a define like _syscall0, _syscall1 ...
What should I do?
Is this problem related with glibc version?
I don't know what I do.
Please help me.
Last edited by SungWon Chung; 11-26-2007 at 12:35 AM.
Well, that’s your problem… There are much better ways to use syscalls from C programs. There is a nice wrapper function called syscall() which comes with glibc (for more information, see “man 2 syscall”). For example (if you use glibc), try something like this for a header file:
Obviously, the #defines are supposed to be the system call numbers themselves. If in implementing your system call, you already changed /usr/include/asm/unistd.h then you don’t need to replicate the #defines (in fact if you do, an error should be thrown). If you didn’t do this (or are distributing your program so that editing a system file would require too much permission), you’ll need to duplicate the macros. In fact, you might add some architecture-specific preprocessing since syscall numbers are arch-specific.
You don’t need to const-qualify the function arguments, since in C all arguments are passed by value.
Whereas in kernelspace, your system calls usually return long, in userspace they are interpreted as ints.
The wrapper function will automatically take care of errno for you. I.e., in case of a negative return value from the actual system call, the wrapper will return -1 and set errno accordingly.
Once you include a file with the above code, you may use the functions as if they were C functions instead of direct system calls.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.