将参数传递给系统调用 [英] Passing parameters to system calls
本文介绍了将参数传递给系统调用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我这样做没有任何参数的基本的helloWorld系统调用的例子,只是:
I did a basic helloWorld system call example that had no parameters and was just:
int main()
{
syscall(__NR_helloWorld);
return 0;
}
但现在我试图找出如何实际参数传递给系统调用(即长)。什么是格式正好,我想:
But now I am trying to figure out how to pass actual arguments to the system call (ie. a long). What is the format exactly, I tried:
int main()
{
long input = 1;
long result = syscall(__NR_someSysCall, long input, long);
return 0;
}
凡需要很长的,并返回一个长,但它未正确编译;什么是正确的语法?
Where it takes a long and returns a long, but it is not compiling correctly; what is the correct syntax?
推荐答案
删除类型名称。这只是一个函数调用。例如:
Remove the type names. It's just a function call. Example:
#include <sys/syscall.h>
#include <unistd.h>
int main( int argc, char* argv[] ) {
char* ptr = "boo\n";
syscall( __NR_write, 1, ptr, 4 ); /* write syscall */
return 0;
}
这篇关于将参数传递给系统调用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文