Expand description
Raw System Calls
This module provides raw and direct access to system calls on linux
platforms. It exports 7 different functions, one for each possible number
of arguments you can pass to a syscall (syscall0
through syscall6
). It
is always safe to use syscall6()
and set unused arguments to any value.
For performance reasons, you might want to prefer the matching call,
though.
This implementation is optimized to allow inlining of the system-call invocation into the calling function. That is, when xLTO is used, the syscall setup and instruction will be inlined into the caller, and thus allows fast and efficient kernel calls. On common architectures, the inline assembly is now stable rust, so no cross-language LTO is needed, anyway.
Linux system calls take between 0 and 6 arguments, each argument is passed as a native integer. Furthermore, every system call has a return value, which also is a native integer. Depending on the platform you run on, the actual underlying datatype will have different size constraints (e.g., on 32bit machines all arguments are usually 32bit integers, but on 64bit machines you pass 64bit integers). You should consult the documentation of each system call to understand how individual arguments are passed. Be warned, there are even system calls that flip argument order depending on the architecture (for historical reasons, trying to provide binary compatibility to existing platforms). Use the wrapper definitions to get a verified function prototype for each system call.
The return value of a system call is limited to a native integer.
Furthermore, 4096 values are reserved for error codes. For most syscalls
it is enough to interpret the return value as signed integer and consider
any negative value as error. However, in some special cases this is not
correct. Therefore, the Retval
type provides small accessors to check
whether the return value is an error code or not. If performance is not
a concern, it also provides a conversion to Result
.
Structs§
- Retval
- System Call Return Value
Functions§
- syscall0⚠
- Invoke System Call With 0 Arguments
- syscall1⚠
- Invoke System Call With 1 Argument
- syscall2⚠
- Invoke System Call With 2 Arguments
- syscall3⚠
- Invoke System Call With 3 Arguments
- syscall4⚠
- Invoke System Call With 4 Arguments
- syscall5⚠
- Invoke System Call With 5 Arguments
- syscall6⚠
- Invoke System Call With 6 Arguments