standard_lib/fs/mod.rs
1//! File-system interface which acts as an abstraction over Linux's syscalls. As such, this crate is
2//! specific to Linux only.
3//!
4//! # Purpose
5//! Doing the research to write this module has taught me heaps about how Linux actually works and
6//! how programs interact with it. It has also helped to clarify what functions the Kernel actually
7//! encompasses.
8//!
9//! # Method
10//! All components of this module are written to target Linux specifically. Although most parts
11//! probably rely on the general POSIX standards, there may be some places where they make use of
12//! Linux-specific extensions or implementation details. As for architecture, I haven't yet decided
13//! whether I'm targeting 64-bit systems specifically or handling all pointer sizes, 64-bit is
14//! certainly the primary target. Beyond pointer width, this should work on architecture thanks to
15//! glibc's platform specific constants.
16//!
17//! Some types in the module very closely resemble [`std::fs`], but others differ significantly.
18//! Notable differences include:
19//! - A [`Directory`] type, which leverages the file descriptor and open syscall's
20//! ability to open and refer to a directory by a descriptor rather then just a path. This could
21//! help to prevent TOCTOU bugs / exploits.
22//! - Distinct absolute ([`Path<Abs>`](Path<Abs>)) and relative
23//! ([`Path<Rel>`](Path<Rel>)) path types with additional formatting invariants for both.
24//! Among other things, this prevents unexpected behavior such as absolute paths replacing each
25//! other when joined (as they do in [`std`]).
26//! - Statically dispatched error types for more explicit error handling.
27#![cfg(target_os = "linux")]
28#![doc(cfg(Linux))]
29
30pub mod dir;
31pub mod error;
32pub mod file;
33pub(crate) mod panic;
34pub mod path;
35
36mod fd;
37mod file_type;
38mod metadata;
39
40pub(crate) use fd::*;
41pub use file_type::*;
42pub use metadata::*;
43
44#[doc(inline)]
45pub use dir::Directory;
46#[doc(inline)]
47pub use file::File;
48#[doc(inline)]
49pub use path::{Abs, OwnedPath, Path, Rel};