Skip to main content

Module sysfs

Module sysfs 

Source
Expand description

§Sysfs interface: reading filesystem and device state from /sys/fs/btrfs/

The kernel exposes per-filesystem information under /sys/fs/btrfs/<uuid>/, where <uuid> is the filesystem UUID as returned by fs_info. This includes commit statistics, feature flags, quota state, and per-device scrub limits.

The primary entry point is SysfsBtrfs, which is constructed from a filesystem UUID and provides typed accessors for each sysfs file:

let info = fs_info(fd).unwrap();
let sysfs = SysfsBtrfs::new(&info.uuid);
println!("label: {}", sysfs.label().unwrap());
println!("quota status: {:?}", sysfs.quota_status().unwrap());

All accessors return std::io::Result and will return an error with kind std::io::ErrorKind::NotFound if the filesystem is not currently mounted.

Structs§

CommitStats
Commit statistics for a mounted btrfs filesystem, read from /sys/fs/btrfs/<uuid>/commit_stats.
QuotaStatus
Quota status for a mounted btrfs filesystem, read from sysfs under /sys/fs/btrfs/<uuid>/qgroups/.
SysfsBtrfs
Provides typed access to the sysfs files exposed for a single mounted btrfs filesystem under /sys/fs/btrfs/<uuid>/.

Functions§

sysfs_btrfs_path
Returns the sysfs directory path for the btrfs filesystem with the given UUID: /sys/fs/btrfs/<uuid>.
sysfs_btrfs_path_file
Returns the path to a named file within the sysfs directory for the filesystem with the given UUID: /sys/fs/btrfs/<uuid>/<name>.