#linux #syscalls #linux-kernel #android

no-std linux-syscalls

A library to easily invoke linux system calls

11 unstable releases (3 breaking)

0.4.0 Feb 3, 2024
0.3.2 Jul 30, 2023
0.2.1 Jul 17, 2023
0.1.4 Jul 7, 2023
0.1.2 Jun 26, 2023

#472 in Unix APIs

32 downloads per month
Used in linux-stat

MIT license

275KB
9K SLoC

Rust 7.5K SLoC // 0.0% comments Shell 846 SLoC // 0.0% comments GNU Style Assembly 828 SLoC // 0.1% comments

linux-syscalls

GitHub Workflow Status (with branch) Crates.io docs.rs Crates.io

A library to easily deal with linux system calls.

One does not simply make a syscall

As a side effect this library offers other utilities.

uname

This library invoke uname syscall in initialization and cache its result.

kernel version

Parse kernel version from uname in initialization (panics if it's invalid) and offers a macro kversion! to deal with it.

auxiliary vector

Detect auxiliary vector (if present) in initialization and offer a Rust interface to query its values. Useful for hardware/kernel features like scv in ppc64.

vDSO

Detect vDSO and parse it (if present) in initialization and store its result. Useful for vsyscalls on any platform and __kernel_vsyscall for faster syscalls on x86 machines.

Feature flags

  • std: enable std support.
  • bare: do not try to automatically initialize the library.
  • libc-compat: forward this feature to linux-errnos.

#![no_std]

Enable #![no_std] support by disabling the default std feature:

[dependencies]
linux-syscalls = { version = "*", default-features = false }

Supported platforms

Tier 1

  • aarch64-unknown-linux-gnu
  • i686-unknown-linux-gnu
  • x86_64-unknown-linux-gnu

Tier 2

  • aarch64-unknown-linux-musl
  • arm-unknown-linux-gnueabi
  • arm-unknown-linux-gnueabihf
  • arm-unknown-linux-musleabi
  • arm-unknown-linux-musleabihf
  • armv5te-unknown-linux-gnueabi
  • armv5te-unknown-linux-musleabi
  • armv7-unknown-linux-gnueabi
  • armv7-unknown-linux-gnueabihf
  • armv7-unknown-linux-musleabi
  • armv7-unknown-linux-musleabihf
  • i586-unknown-linux-gnu
  • i586-unknown-linux-musl
  • i686-unknown-linux-musl
  • loongarch64-unknown-linux-gnu
  • mips-unknown-linux-gnu (not tested)
  • mips-unknown-linux-musl (not tested)
  • mips64-unknown-linux-gnuabi64 (not tested)
  • mips64-unknown-linux-muslabi64 (not tested)
  • mips64el-unknown-linux-gnuabi64 (not tested)
  • mips64el-unknown-linux-muslabi64 (not tested)
  • mipsel-unknown-linux-gnu (not tested)
  • mipsel-unknown-linux-musl (not tested)
  • powerpc-unknown-linux-gnu
  • powerpc64-unknown-linux-gnu
  • powerpc64le-unknown-linux-gnu
  • riscv64gc-unknown-linux-gnu
  • s390x-unknown-linux-gnu
  • thumbv7neon-unknown-linux-gnueabihf
  • x86_64-unknown-linux-musl

MSRV

1.65.0

Dependencies

~1.5MB
~18K SLoC