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 ;
// Parse an fstab file
let input = "\
# /etc/fstab
UUID=abc-123 / ext4 defaults 0 1
UUID=def-456 /boot ext4 defaults 0 2
/swap.img none swap sw 0 0
";
let fstab = parse_str.unwrap;
// Inspect entries
assert_eq!;
let root = fstab.root.unwrap;
assert!;
// Edit entries
let mut fstab = parse_str.unwrap;
fstab
.add
.remove; // Remove /boot
// Validate
for diag in fstab.validate
// Atomic write
fstab.write_atomic.unwrap;
Features
- Parse -- Full fstab(5) format: all tag types (LABEL, UUID, PARTLABEL, PARTUUID, ID), NFS mounts, escape sequences, comments
- Edit -- CRUD API with order preservation and comment tracking
- Validate -- Semantic checks matching
findmnt --verify - Serialize --
Displayformatting with proper escape encoding - Atomic write --
tempfile -> fsync -> renamefor safe file updates - Type safety -- Every field is a validated type, not a raw string
- serde -- Optional Serialize/Deserialize support
Installation
[]
= "0.1"
For serde support:
[]
= { = "0.1", = ["serde"] }
Minimum Supported Rust Version
Rust 1.95 or later.
License
Licensed under the MIT license. See LICENSE for details.