Skip to main content

Crate mount_fstab

Crate mount_fstab 

Source
Expand description

§mount-fstab

A 100% type-safe, memory-safe, thread-safe Rust library for parsing, editing, validating, and writing /etc/fstab files.

Implements the official fstab(5) semantics from util-linux, aligned with libmount and glibc parsing behavior.

§Quick start

use mount_fstab::Fstab;

let input = "UUID=root / ext4 defaults 0 1\n";
let fstab = Fstab::parse_str(input).unwrap();
assert_eq!(fstab.entries.len(), 1);

§Modules

ModuleDescription
errorError types for all parsing and validation operations
escapefstab escape sequence encoding and decoding
fstypeFilesystem type (fstab field 3)
optionsMount options (fstab field 4) with parsing and classification
parsefstab string and file parsing
specSpec/source identifiers (fstab field 1)
typesCore types: Entry, Fstab, MountPoint, EntryBuilder
validateSemantic validation of fstab entries
writeDisplay formatting and atomic file writing

§Features

  • Parse: Full fstab(5) format including all tag types (LABEL, UUID, PARTLABEL, PARTUUID, ID), NFS mounts, escape sequences
  • Edit: Add, remove, replace entries with CRUD API
  • Validate: Semantic checks matching findmnt --verify
  • Serialize: Display formatting with proper escape encoding
  • Atomic write: tempfile -> fsync -> rename for safe file updates

Re-exports§

pub use error::EntryBuilderError;
pub use error::FsTypeError;
pub use error::FstabError;
pub use error::MountPointError;
pub use error::OptItemError;
pub use error::OptionsError;
pub use error::ParseErrorKind;
pub use error::SpecError;
pub use fstype::FsType;
pub use options::MountPermission;
pub use options::OptItem;
pub use options::OptionClass;
pub use options::Options;
pub use spec::Spec;
pub use types::Entry;
pub use types::EntryBuilder;
pub use types::Fstab;
pub use types::MountPoint;
pub use validate::Diagnostic;
pub use validate::Severity;

Modules§

error
Error types for all fstab parsing and validation operations.
escape
fstab escape sequence encoding and decoding.
fstype
Filesystem type — fstab(5) field 3 (fs_vfstype).
options
Mount options — fstab(5) field 4 (fs_mntops).
parse
fstab string and file parsing.
spec
Filesystem source specifiers — fstab(5) field 1.
types
Core fstab types: Entry, Fstab, MountPoint, EntryBuilder.
validate
Semantic validation of fstab entries.
write
fstab serialization and file writing.