KevinD
KevinD

Reputation: 69

Golang, calling a new system call in Linux

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.

Upvotes: 2

Views: 3655

Answers (1)

Mr_Pink
Mr_Pink

Reputation: 109347

The syscall package has syscall.Syscall and syscall.Syscall6 to make syscalls directly.

Upvotes: 6

Related Questions