仍然致力于此系统调用!!!
我已经向内核添加了一个系统调用,已编译并且操作系统正在运行它。
现在我在编译测试应用程序时遇到语法错误。
testmycall.h
#include<linux/unistd.h>
#define __NR_mycall 244
_syscall1(long, mycall, int, i)
testmycall.c
#include<stdio.h>
#include "testmycall.h"
int main(int argc, char *argv[])
{
printf("%d\n", mycall(15));
}
这是错误
stef@ubuntu:~$ gcc -o testmycall testmycall.c
In file included from testmycall.c:3:
testmycall.h:7: error: expected ‘)’ before ‘mycall’
stef@ubuntu:~$ gcc -o testmycall testmycall.c
In file included from testmycall.c:3:
testmycall.h:7: error: expected declaration specifiers or ‘...’ before ‘mycall’
testmycall.h:7: error: expected declaration specifiers or ‘...’ before ‘i’
testmycall.c: In function ‘_syscall1’:
testmycall.c:7: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token
testmycall.h:7: error: parameter name omitted
testmycall.h:7: error: parameter name omitted
testmycall.c:11: error: expected ‘{’ at end of input
stef@ubuntu
我在系统调用中添加了而不是_syscall1
现在我收到此错误
stef@ubuntu:~$ gcc -o testmycall testmycall.c
testmycall.c: In function ‘syscall’:
testmycall.c:7: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token
testmycall.c:11: error: expected ‘{’
这是应用程序,任何想法为什么???
答案 0 :(得分:2)
我相信_syscallN()
宏已经从2.6.18左右的内核头文件中删除了。
来自gcc的(不是特别有帮助的)错误消息是由于_syscall1
根本没有定义 - 如果你写的话会得到相同的错误:
any_old_rubbish_here(long, mycall, int, i)
syscall()
功能应该有效。 man syscall
了解详情。
答案 1 :(得分:1)