by btdmaster on 11/1/24, 10:14 PM with 116 comments
by sph on 11/7/24, 11:34 AM
https://github.com/torvalds/linux/tree/master/tools/include/...
A sample use-case? I was developing an Erlang-like actor platform that should operate under Linux as well as a bare-metal microkernel, and all I needed is a light layer over syscalls instead of pulling the entire glibc. Also it provides a simple implementation for standard C functions (memcpy, printf) so I don't have to write them myself.
by sedatk on 11/7/24, 6:31 PM
by kentonv on 11/7/24, 2:28 PM
The kernel actually signals errors by returning a negative error code (on most arches), which seems like a better calling convention. Storing errors in something like `errno` opens a whole can of worms around thread safety and signal safety, while seemingly providing very little benefit beyond following tradition.
by Aransentin on 11/7/24, 3:21 PM
Sometimes you actually want to make sure that the exact syscall is called; e.g. you're writing a little program protected by strict seccomp rules. If the layer can magically call some other syscall under the hood this won't work anymore.
by zamalek on 11/8/24, 12:08 AM
by IAmLiterallyAB on 11/7/24, 1:38 PM
by iTokio on 11/7/24, 7:32 PM
by jagrsw on 11/7/24, 1:08 PM
For example, on a 64-bit arch, this code would be sus.
syscall(__NR_syscall_taking_6_args, 1, 2, 3, 4, 5, 6);
Quiz: why
PS: it's a common mistake, so I thought I'd save you a trip down the debugging rabbit hole.
by mcnichol on 11/7/24, 5:33 PM
by wg0 on 11/7/24, 3:09 PM