英文:
Golang, calling a new system call in Linux
问题
我有一个带有自定义系统调用的Linux内核。在C语言中,我可以使用标准C库的syscall()函数通过系统调用号来调用系统调用。那么在Go语言中,我该如何调用这个新的系统调用呢?
在Linux上的C语言中,还有一些宏可以生成所需的内联汇编代码来直接进行系统调用。
我不想修改syscall_linux.go文件。
我看到在Go语言中,syscall_linux.go文件是通过一个Perl脚本(mysyscall.pl)进行处理,以生成汇编代码。这也相当复杂,而且修改它以生成新的存根似乎也是不必要的混乱。
英文:
I have a Linux kernel with a custom system call. In C, I can use the standard C library syscall() to call a system call by its number. How can I call this new system call in Go?
In C, on Linux, there are also macros that can emit the needed inline assembly to make a system call directly.
I would hate to have to hack syscall_linux.go.
I see that in Go, syscall_linux.go is processed by a perl script (mysyscall.pl) to generate assembly. That is also pretty complicated and hacking it to generate a new stub also seems needlessly messy.
答案1
得分: 6
syscall
包提供了 syscall.Syscall
和 syscall.Syscall6
函数,可以直接进行系统调用。
英文:
The syscall
package has syscall.Syscall
and syscall.Syscall6
to make syscalls directly.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论