Skip to main content

xfs/
lib.rs

1//! `xfs-core` — a pure-Rust, from-scratch XFS filesystem reader.
2//!
3//! Parses the on-disk XFS structures a forensic tool needs — superblock and
4//! geometry, allocation-group headers, inodes, extents, and the five directory
5//! formats — over any byte source. The reader targets both v4 (legacy) and v5
6//! (self-describing CRC-stamped) filesystems.
7//!
8//! Import path is `xfs` (see `[lib] name`): `use xfs::Superblock;`.
9//!
10//! # Safety and robustness
11//!
12//! This crate parses untrusted, attacker-controllable disk images. It is
13//! `#![forbid(unsafe_code)]` and every integer is read through bounds-checked
14//! big-endian helpers that yield `0`/`None` out of range rather than panic
15//! (the Paranoid Gatekeeper standard).
16
17#![forbid(unsafe_code)]
18#![cfg_attr(test, allow(clippy::unwrap_used, clippy::expect_used))]
19
20mod agheaders;
21mod btree;
22pub mod bytes;
23pub mod crc;
24mod dir;
25mod error;
26mod extent;
27mod inode;
28mod superblock;
29#[cfg(feature = "vfs")]
30pub mod vfs;
31
32pub use agheaders::{
33    Agf, Agfl, Agi, XFS_AGFL_MAGIC, XFS_AGF_MAGIC, XFS_AGI_MAGIC, XFS_AGI_UNLINKED_BUCKETS,
34};
35pub use btree::{
36    read_btree_extents, verify_bmbt_block_crc, MAX_BMBT_LEVELS, MAX_BMBT_PTRS, XFS_BMAP_CRC_MAGIC,
37    XFS_BMAP_MAGIC,
38};
39pub use crc::{crc_status, verify_crc};
40pub use dir::{
41    read_block_dir, read_by_path, read_data_dir_block, read_dir, read_shortform_dir,
42    verify_dir_block_crc, DirEntry, XFS_DIR2_BLOCK_MAGIC, XFS_DIR2_DATA_MAGIC,
43    XFS_DIR3_BLOCK_MAGIC, XFS_DIR3_DATA_MAGIC,
44};
45pub use error::XfsError;
46pub use extent::{assemble_extents, read_extents, read_file_from_fork, BmbtRec};
47pub use inode::{
48    FileType, Inode, InodeFormat, XfsTimestamp, XFS_DIFLAG2_BIGTIME, XFS_DINODE_MAGIC,
49};
50pub use superblock::{InodeLocation, Superblock, XFS_SB_MAGIC};