{"id":13504036,"url":"https://github.com/bytecodealliance/rustix","last_synced_at":"2025-12-12T16:35:06.685Z","repository":{"id":37515391,"uuid":"295544240","full_name":"bytecodealliance/rustix","owner":"bytecodealliance","description":"Safe Rust bindings to POSIX-ish APIs","archived":false,"fork":false,"pushed_at":"2025-04-01T13:55:37.000Z","size":6778,"stargazers_count":1646,"open_issues_count":66,"forks_count":190,"subscribers_count":21,"default_branch":"main","last_synced_at":"2025-04-04T06:07:17.890Z","etag":null,"topics":["linux","posix","rust","safe"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bytecodealliance.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGES.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE-APACHE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-09-14T21:35:44.000Z","updated_at":"2025-04-04T02:13:30.000Z","dependencies_parsed_at":"2023-12-18T23:29:42.717Z","dependency_job_id":"69c788c2-5217-4a67-93ef-3d089c4940c4","html_url":"https://github.com/bytecodealliance/rustix","commit_stats":{"total_commits":1951,"total_committers":95,"mean_commits":20.53684210526316,"dds":"0.13172731932342385","last_synced_commit":"74bcc3515b3caa3198fa7da787174f44682be1d6"},"previous_names":["bytecodealliance/rsix"],"tags_count":243,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bytecodealliance%2Frustix","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bytecodealliance%2Frustix/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bytecodealliance%2Frustix/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bytecodealliance%2Frustix/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bytecodealliance","download_url":"https://codeload.github.com/bytecodealliance/rustix/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247406071,"owners_count":20933802,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["linux","posix","rust","safe"],"created_at":"2024-07-31T23:00:52.875Z","updated_at":"2025-12-12T16:35:06.619Z","avatar_url":"https://github.com/bytecodealliance.png","language":"Rust","readme":"\u003cdiv align=\"center\"\u003e\n  \u003ch1\u003e\u003ccode\u003erustix\u003c/code\u003e\u003c/h1\u003e\n\n  \u003cp\u003e\n    \u003cstrong\u003eSafe Rust bindings to POSIX/Unix/Linux/Winsock syscalls\u003c/strong\u003e\n  \u003c/p\u003e\n\n  \u003cstrong\u003eA \u003ca href=\"https://bytecodealliance.org/\"\u003eBytecode Alliance\u003c/a\u003e project\u003c/strong\u003e\n\n  \u003cp\u003e\n    \u003ca href=\"https://github.com/bytecodealliance/rustix/actions?query=workflow%3ACI\"\u003e\u003cimg src=\"https://github.com/bytecodealliance/rustix/workflows/CI/badge.svg\" alt=\"Github Actions CI Status\" /\u003e\u003c/a\u003e\n    \u003ca href=\"https://bytecodealliance.zulipchat.com/#narrow/stream/206238-general\"\u003e\u003cimg src=\"https://img.shields.io/badge/zulip-join_chat-brightgreen.svg\" alt=\"zulip chat\" /\u003e\u003c/a\u003e\n    \u003ca href=\"https://crates.io/crates/rustix\"\u003e\u003cimg src=\"https://img.shields.io/crates/v/rustix.svg\" alt=\"crates.io page\" /\u003e\u003c/a\u003e\n    \u003ca href=\"https://docs.rs/rustix\"\u003e\u003cimg src=\"https://docs.rs/rustix/badge.svg\" alt=\"docs.rs docs\" /\u003e\u003c/a\u003e\n  \u003c/p\u003e\n\u003c/div\u003e\n\n`rustix` provides efficient memory-safe and [I/O-safe] wrappers to POSIX-like,\nUnix-like, Linux, and Winsock syscall-like APIs, with configurable backends. It\nuses Rust references, slices, and return values instead of raw pointers, and\n[I/O safety types] instead of raw file descriptors, providing memory safety,\n[I/O safety], and [provenance]. It uses `Result`s for reporting errors,\n[`bitflags`] instead of bare integer flags, an [`Arg`] trait with optimizations\nto efficiently accept any Rust string type, and several other efficient\nconveniences.\n\n`rustix` is low-level and, and while the `net` API supports [Windows Sockets 2]\n(Winsock), the rest of the APIs do not support Windows; for higher-level and\nmore portable APIs built on this functionality, see the [`cap-std`], [`memfd`],\n[`timerfd`], and [`io-streams`] crates, for example.\n\n`rustix` currently has two backends available:\n\n * linux_raw, which uses raw Linux system calls and vDSO calls, and is\n   supported on Linux on x86-64, x86, aarch64, riscv64gc, powerpc64le,\n   arm (v5 onwards), mipsel, and mips64el, with stable, nightly, and 1.63 Rust.\n    - By being implemented entirely in Rust, avoiding `libc`, `errno`, and pthread\n      cancellation, and employing some specialized optimizations, most functions\n      compile down to very efficient code, which can often be fully inlined into\n      user code.\n    - Most functions in `linux_raw` preserve memory, I/O safety, and pointer\n      provenance all the way down to the syscalls.\n\n * libc, which uses the [`libc`] crate which provides bindings to native `libc`\n   libraries on Unix-family platforms, and [`windows-sys`] for Winsock on\n   Windows, and is portable to many OS's.\n\nThe linux_raw backend is enabled by default on platforms which support it. To\nenable the libc backend instead, either enable the \"use-libc\" cargo feature, or\nset the `RUSTFLAGS` environment variable to `--cfg=rustix_use_libc` when\nbuilding.\n\n## Cargo features\n\nThe modules [`rustix::io`], [`rustix::buffer`], [`rustix::fd`],\n[`rustix::ffi`], and [`rustix::ioctl`] are enabled by default. The rest of the\nAPI modules are conditional with cargo feature flags.\n\n| Name       | Description                                                    |\n| ---------- | -------------------------------------------------------------- |\n| `event`    | [`rustix::event`]—Polling and event operations.                |\n| `fs`       | [`rustix::fs`]—Filesystem operations.                          |\n| `io_uring` | [`rustix::io_uring`]—Linux io_uring.                           |\n| `mm`       | [`rustix::mm`]—Memory map operations.                          |\n| `mount`    | [`rustix::mount`]—Linux mount API.                             |\n| `net`      | [`rustix::net`]—Network-related operations.                    |\n| `param`    | [`rustix::param`]—Process parameters.                          |\n| `pipe`     | [`rustix::pipe`]—Pipe operations.                              |\n| `process`  | [`rustix::process`]—Process-associated operations.             |\n| `pty`      | [`rustix::pty`]—Pseudoterminal operations.                     |\n| `rand`     | [`rustix::rand`]—Random-related operations.                    |\n| `shm`      | [`rustix::shm`]—POSIX shared memory.                           |\n| `stdio`    | [`rustix::stdio`]—Stdio-related operations.                    |\n| `system`   | [`rustix::system`]—System-related operations.                  |\n| `termios`  | [`rustix::termios`]—Terminal I/O stream operations.            |\n| `thread`   | [`rustix::thread`]—Thread-associated operations.               |\n| `time`     | [`rustix::time`]—Time-related operations.                      |\n|            |                                                                |\n| `use-libc` | Enable the libc backend.                                       |\n|            |                                                                |\n| `linux_4_11`    | Enable optimizations that assume Linux ≥ 4.11             |\n| `linux_5_1`     | Enable optimizations that assume Linux ≥ 5.1              |\n| `linux_5_11`    | Enable optimizations that assume Linux ≥ 5.11             |\n| `linux_latest`  | Enable optimizations that assume the latest Linux release |\n|                 |                                                           |\n| `use-libc-auxv` | Use `getauxval` instead of `PR_GET_AUXV` or \"/proc/self/auxv\". |\n|                 |                                                           |\n| `std`      | On by default; disable to activate `#![no_std]`.               |\n| `alloc`    | On by default; enables features that depend on [`alloc`].      |\n\n[`rustix::buffer`]: https://docs.rs/rustix/*/rustix/buffer/index.html\n[`rustix::event`]: https://docs.rs/rustix/*/rustix/event/index.html\n[`rustix::fs`]: https://docs.rs/rustix/*/rustix/fs/index.html\n[`rustix::io_uring`]: https://docs.rs/rustix/*/rustix/io_uring/index.html\n[`rustix::mm`]: https://docs.rs/rustix/*/rustix/mm/index.html\n[`rustix::mount`]: https://docs.rs/rustix/*/rustix/mount/index.html\n[`rustix::net`]: https://docs.rs/rustix/*/rustix/net/index.html\n[`rustix::param`]: https://docs.rs/rustix/*/rustix/param/index.html\n[`rustix::pipe`]: https://docs.rs/rustix/*/rustix/pipe/index.html\n[`rustix::process`]: https://docs.rs/rustix/*/rustix/process/index.html\n[`rustix::pty`]: https://docs.rs/rustix/*/rustix/pty/index.html\n[`rustix::rand`]: https://docs.rs/rustix/*/rustix/rand/index.html\n[`rustix::shm`]: https://docs.rs/rustix/*/rustix/shm/index.html\n[`rustix::stdio`]: https://docs.rs/rustix/*/rustix/stdio/index.html\n[`rustix::system`]: https://docs.rs/rustix/*/rustix/system/index.html\n[`rustix::termios`]: https://docs.rs/rustix/*/rustix/termios/index.html\n[`rustix::thread`]: https://docs.rs/rustix/*/rustix/thread/index.html\n[`rustix::time`]: https://docs.rs/rustix/*/rustix/time/index.html\n[`rustix::io`]: https://docs.rs/rustix/*/rustix/io/index.html\n[`rustix::fd`]: https://docs.rs/rustix/*/rustix/fd/index.html\n[`rustix::ffi`]: https://docs.rs/rustix/*/rustix/ffi/index.html\n[`rustix::ioctl`]: https://docs.rs/rustix/*/rustix/ffi/ioctl.html\n\n## 64-bit Large File Support (LFS) and Year 2038 (y2038) support\n\n`rustix` automatically uses 64-bit APIs when available, and avoids exposing\n32-bit APIs that would have the year-2038 problem or fail to support large\nfiles. For instance, `rustix::fstatvfs` calls `fstatvfs64`, and returns a\nstruct that's 64-bit even on 32-bit platforms.\n\n## Similar crates\n\n`rustix` is similar to [`nix`], [`simple_libc`], [`unix`], [`nc`], [`uapi`],\nand [`rusl`]. `rustix` is architected for [I/O safety] with most APIs using\n[`OwnedFd`] and [`AsFd`] to manipulate file descriptors rather than `File` or\neven `c_int`, and supporting multiple backends so that it can use direct\nsyscalls while still being usable on all platforms `libc` supports. Like `nix`,\n`rustix` has an optimized and flexible filename argument mechanism that allows\nusers to use a variety of string types, including non-UTF-8 string types.\n\n[`relibc`] is a similar project which aims to be a full \"libc\", including\nC-compatible interfaces and higher-level C/POSIX standard-library\nfunctionality; `rustix` just aims to provide safe and idiomatic Rust interfaces\nto low-level syscalls. `relibc` also doesn't tend to support features not\nsupported on Redox, such as `*at` functions like `openat`, which are important\nfeatures for `rustix`.\n\n`rustix` has its own code for making direct syscalls, similar to the\n[`syscall`], [`sc`], and [`scall`] crates, using the Rust `asm!` macro.\n`rustix` can also use Linux's vDSO mechanism to optimize Linux `clock_gettime`\non all architectures, and all Linux system calls on x86. And `rustix`'s\nsyscalls report errors using an optimized `Errno` type.\n\n`rustix`'s `*at` functions are similar to the [`openat`] crate, but `rustix`\nprovides them as free functions rather than associated functions of a `Dir`\ntype. `rustix`'s `CWD` constant exposes the special `AT_FDCWD` value in a safe\nway, so users don't need to open `.` to get a current-directory handle.\n\n`rustix`'s `openat2` function is similar to the [`openat2`] crate, but uses I/O\nsafety types rather than `RawFd`. `rustix` does not provide dynamic feature\ndetection, so users must handle the [`NOSYS`] error themselves.\n\n`rustix`'s `termios` module is similar to the [`termios`] crate, but uses I/O\nsafety types rather than `RawFd`, and the flags parameters to functions such as\n`tcsetattr` are `enum`s rather than bare integers. And, rustix calls its\n`tcgetattr` function `tcgetattr`, rather than `Termios::from_fd`.\n\n## Minimum Supported Rust Version (MSRV)\n\nThis crate currently works on the version of [Rust on Debian stable], which is\ncurrently [Rust 1.63]. This policy may change in the future, in minor version\nreleases, so users using a fixed version of Rust should pin to a specific\nversion of this crate.\n\n## Minimum Linux Version\n\nOn Linux platforms, rustix requires at least Linux 3.2. This is at most the\noldest Linux version supported by:\n - [any current Rust target], or\n - [kernel.org] at the time of rustix's [MSRV] release.\nThe specifics of this policy may change in the future, but we intend it to\nalways reflect “very old” Linux versions.\n\n[MSRV]: #minimum-supported-rust-version-msrv\n[Rust 1.63]: https://blog.rust-lang.org/2022/08/11/Rust-1.63.0.html\n[any current Rust target]: https://doc.rust-lang.org/nightly/rustc/platform-support.html\n[kernel.org]: https://www.kernel.org/releases.html\n[Rust on Debian stable]: https://packages.debian.org/stable/rust/rustc\n[Windows Sockets 2]: https://learn.microsoft.com/en-us/windows/win32/winsock/windows-sockets-start-page-2\n[`nix`]: https://crates.io/crates/nix\n[`unix`]: https://crates.io/crates/unix\n[`nc`]: https://crates.io/crates/nc\n[`simple_libc`]: https://crates.io/crates/simple_libc\n[`uapi`]: https://crates.io/crates/uapi\n[`rusl`]: https://lib.rs/crates/rusl\n[`relibc`]: https://gitlab.redox-os.org/redox-os/relibc\n[`syscall`]: https://crates.io/crates/syscall\n[`sc`]: https://crates.io/crates/sc\n[`scall`]: https://crates.io/crates/scall\n[`openat`]: https://crates.io/crates/openat\n[`openat2`]: https://crates.io/crates/openat2\n[I/O safety types]: https://doc.rust-lang.org/stable/std/os/fd/index.html#structs\n[`termios`]: https://crates.io/crates/termios\n[`libc`]: https://crates.io/crates/libc\n[`windows-sys`]: https://crates.io/crates/windows-sys\n[`cap-std`]: https://crates.io/crates/cap-std\n[`memfd`]: https://crates.io/crates/memfd\n[`timerfd`]: https://crates.io/crates/timerfd\n[`io-streams`]: https://crates.io/crates/io-streams\n[`bitflags`]: https://crates.io/crates/bitflags\n[`Arg`]: https://docs.rs/rustix/*/rustix/path/trait.Arg.html\n[I/O-safe]: https://github.com/rust-lang/rfcs/blob/master/text/3128-io-safety.md\n[I/O safety]: https://github.com/rust-lang/rfcs/blob/master/text/3128-io-safety.md\n[provenance]: https://github.com/rust-lang/rust/issues/95228\n[`OwnedFd`]: https://doc.rust-lang.org/stable/std/os/fd/struct.OwnedFd.html\n[`AsFd`]: https://doc.rust-lang.org/stable/std/os/fd/trait.AsFd.html\n[`NOSYS`]: https://docs.rs/rustix/*/rustix/io/struct.Errno.html#associatedconstant.NOSYS\n[`alloc`]: https://doc.rust-lang.org/alloc/alloc/index.html\n","funding_links":[],"categories":["Rust","Libraries","库 Libraries"],"sub_categories":["Platform specific","特定于平台的 Platform specific"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbytecodealliance%2Frustix","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbytecodealliance%2Frustix","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbytecodealliance%2Frustix/lists"}