#file-descriptor #syscalls #linux #calls #abstraction #direct #wrapper

no-std linux-io

Lightweight abstractions around Linux system calls related to file descriptors

6 releases (breaking)

0.6.0 Feb 21, 2023
0.5.0 Feb 19, 2023
0.4.0 Feb 13, 2023
0.3.0 Feb 11, 2023
0.1.0 Feb 5, 2023

#885 in Unix APIs

37 downloads per month
Used in linux-kvm

MIT license

175KB
3.5K SLoC

linux-io crate for Rust

This crate offers some lightweight wrappers around direct Linux system calls related to file descriptors.

The goal is to make it convenient to work with the Linux system call interface and bypass std/libc without introducing any unnecessary additional abstractions beyond slight transformations of argument types and return values.

let mut f = File::create_raw(filename, 0o666)?
f.write_all(message)?; // (using the std::io::Write trait)
f.close()?;

By default this crate implements traits from the standard library where they make sense, but you can disable the default crate feature named std to remove those trait implementations and thereby make this crate usable in no_std environments.


lib.rs:

Lightweight but safe abstractions around Linux system calls related to file descriptors.

This goal of this crate is to expose a convenient API while skipping any unnecessary abstraction. In most cases calls to functions in this crate should reduce to inline system calls and some minimal argument and result conversion code, and the results should be generally unsurprising to anyone who is familiar with the underlying system call behavior.

The functions in this crate wrap functions in crate linux_unsafe to actually make the system calls, and so the platform support for this crate is limited to what that other crate supports.

Implements standard library I/O traits by default, but can be made friendly to no_std environments by disabling the default feature std.

The initial versions of this crate are focused only on basic file operations, until the API for that feels settled. In later releases the scope will hopefully increase to cover most or all of the system calls that work with file descriptors.

Dependencies