Skip to main content

Crate oscall

Crate oscall 

Source
Expand description

Low-level cross-platform interface to operating system services.

oscall talks to the operating system directly, with no dependencies:

  • Linux (and fullrust): raw system calls, no libc involved.
  • macOS: libSystem, the only stable interface to the kernel.
  • Windows: kernel32, ntdll and ws2_32.
  • WebAssembly: WASI preview 1 imports; without WASI, the calls that need a system fail with ErrorKind::Unsupported.

Every function maps onto one operating system operation, or onto the few needed to give the same result everywhere. There is no buffering, no global state and no hidden allocation.

The modules are portable: a function does the same thing on every system, and what one system alone offers is in a sub-module named after it (mem::linux, fs::unix…). For what oscall does not cover, raw gives the layer underneath, which is specific to each system and unsafe: the system call itself on Linux, and the error conventions and string conversions the system libraries need elsewhere.

Modules§

event
Waiting for sockets and handles to become ready.
fs
Files, directories and their metadata.
io
Reading and writing on any handle, pipes, and the standard handles.
mem
Memory: pages, mappings and their protection.
net
Sockets: TCP, UDP and Unix-domain, their addresses and their options.
process
Processes: the current one, and child processes.
rand
The operating system’s random number generator.
raw
The raw layer: what oscall itself is built on, for whatever the portable modules lack.
sync
Waiting on a value in memory, and waking the waiters: the primitive mutexes, condition variables and other locks are built from.
thread
The calling thread: its identity, its name, yielding the processor, and how many processors there are to share.
time
Clocks and sleeping.

Structs§

BorrowedHandle
A handle borrowed from its owner.
Error
An error reported by the operating system.
OwnedHandle
An owned handle to an operating system object: an open file, a pipe, a directory, a process… It is closed when dropped.

Enums§

ErrorKind
A portable classification of Errors.

Traits§

AsHandle
Types that hold a handle.
AsPath
A path argument.

Type Aliases§

RawHandle
The operating system’s own handle type: a file descriptor (i32) on Linux, macOS and WASI, a HANDLE (*mut c_void) on Windows.
Result
The result of an operating system call.