rust-system-calls
Installation
SKILL.md
System Calls & File I/O in Rust
Use bun_sys instead of std::fs or raw libc for cross-platform syscalls with proper error handling.
bun_sys::File (Preferred)
For most file operations, use the bun_sys::File wrapper. It owns the fd and closes on Drop.
use bun_sys::{File, Fd, O};
let file = File::openat(Fd::cwd(), b"path/to/file", O::RDONLY, 0)?;
let mut buf = vec![0u8; 4096];
let n = file.read_all(&mut buf)?; // loops until EOF or full
// `file` closes on Drop.