39 releases

0.6.18 Mar 16, 2024
0.6.15 Oct 11, 2023
0.6.13 Jun 20, 2023
0.6.9 Mar 23, 2023
0.1.4 Oct 1, 2019

#23 in Unix APIs

Download history 1160/week @ 2024-07-21 846/week @ 2024-07-28 1189/week @ 2024-08-04 1446/week @ 2024-08-11 1443/week @ 2024-08-18 2067/week @ 2024-08-25 1417/week @ 2024-09-01 2260/week @ 2024-09-08 2120/week @ 2024-09-15 1841/week @ 2024-09-22 1831/week @ 2024-09-29 2282/week @ 2024-10-06 1537/week @ 2024-10-13 1173/week @ 2024-10-20 1113/week @ 2024-10-27 1154/week @ 2024-11-03

5,074 downloads per month
Used in 8 crates (7 directly)

BSD-2-Clause

1MB
9K SLoC

syscalls

Crates.io docs.rs License

This is a low-level library for listing and invoking raw Linux system calls.

Features

  • Provides a syscall enum for multiple architectures (see table below).
  • Provides inlinable syscall functions for multiple architectures (see table below).
  • Provides an Errno type for Rustic error handling.
  • Provides O(1) array-backed SysnoSet and SysnoMap types.

Feature Flags

The features that are enabled by default include std and serde.

std

By default, std support is enabled. If you wish to compile in a no_std environment, use:

syscalls = { version = "0.6", default-features = false }

serde

Various types can be serialized with Serde. This can be enabled with:

syscalls = { version = "0.6", features = ["serde"] }

full

Enables all extra features.

all

Enables syscall tables for all architectures. If you don't need all architectures, you can enable them individually with features like arm, x86, powerpc, etc. See the Architecture Support table below for a full list of available architectures.

Architecture Support

The Enum column means that a Sysno enum is implemented for this architecture.

The Invoke column means that syscalls can be invoked for this architecture.

The Stable Rust? column means that syscall invocation only requires stable Rust. Some architectures require nightly Rust because inline assembly is not yet stabilized for all architectures.

Arch Enum Invoke Stable Rust?
arm* Yes ✅
aarch64 Yes ✅
mips No ❌
mips64 No ❌
powerpc No ❌
powerpc64 No ❌
riscv32 ❌† No ❌
riscv64 Yes ✅
s390x No ❌
sparc N/A
sparc64 N/A
x86 Yes ✅
x86_64 Yes ✅

* Includes ARM thumb mode support.

† Rust does not support riscv32 Linux targets, but syscall functions are implemented if you're feeling adventurous.

Updating the syscall list

Updates are pulled from the .tbl files in the Linux source tree.

  1. Change the Linux version in syscalls-gen/src/main.rs to the latest version. Only update to the latest stable version (not release candidates).
  2. Run cd syscalls-gen && cargo run. This will regenerate the syscall tables in src/arch/.

Dependencies

~0.3–1MB
~21K SLoC