pub struct SysfsBtrfs { /* private fields */ }Expand description
Provides typed access to the sysfs files exposed for a single mounted btrfs
filesystem under /sys/fs/btrfs/<uuid>/.
Implementations§
Source§impl SysfsBtrfs
impl SysfsBtrfs
Sourcepub fn new(uuid: &Uuid) -> Self
pub fn new(uuid: &Uuid) -> Self
Create a new SysfsBtrfs for the filesystem with the given UUID.
Sourcepub fn bg_reclaim_threshold(&self) -> Result<u64>
pub fn bg_reclaim_threshold(&self) -> Result<u64>
Background reclaim threshold as a percentage (0-100).
/sys/fs/btrfs/<uuid>/bg_reclaim_threshold
§Errors
Returns Err if the sysfs file cannot be read or parsed.
Sourcepub fn checksum(&self) -> Result<String>
pub fn checksum(&self) -> Result<String>
Checksum algorithm in use, e.g. "crc32c (crc32c-lib)".
/sys/fs/btrfs/<uuid>/checksum
§Errors
Returns Err if the sysfs file cannot be read.
Sourcepub fn clone_alignment(&self) -> Result<u64>
pub fn clone_alignment(&self) -> Result<u64>
Minimum clone/reflink alignment in bytes.
/sys/fs/btrfs/<uuid>/clone_alignment
§Errors
Returns Err if the sysfs file cannot be read or parsed.
Sourcepub fn commit_stats(&self) -> Result<CommitStats>
pub fn commit_stats(&self) -> Result<CommitStats>
Commit statistics since mount (or last reset).
/sys/fs/btrfs/<uuid>/commit_stats
§Errors
Returns Err if the sysfs file cannot be read or parsed.
Sourcepub fn reset_commit_stats(&self) -> Result<()>
pub fn reset_commit_stats(&self) -> Result<()>
Reset the max_commit_ms counter by writing 0 to the commit_stats
file. Requires root.
/sys/fs/btrfs/<uuid>/commit_stats
§Errors
Returns Err if the write fails.
Sourcepub fn exclusive_operation(&self) -> Result<String>
pub fn exclusive_operation(&self) -> Result<String>
Name of the exclusive operation currently running, e.g. "none",
"balance", "device add".
/sys/fs/btrfs/<uuid>/exclusive_operation
§Errors
Returns Err if the sysfs file cannot be read.
Sourcepub fn wait_for_exclusive_operation(&self) -> Result<String>
pub fn wait_for_exclusive_operation(&self) -> Result<String>
Wait until no exclusive operation is running on the filesystem.
Polls the exclusive_operation sysfs file at one-second intervals.
Returns immediately if no exclusive operation is in progress, or after
the running operation completes. Returns the name of the operation
that was waited on, or "none" if nothing was running.
§Errors
Returns Err if reading the sysfs file fails.
Sourcepub fn features(&self) -> Result<Vec<String>>
pub fn features(&self) -> Result<Vec<String>>
Names of the filesystem features that are enabled. Each feature
corresponds to a file in the features/ subdirectory.
/sys/fs/btrfs/<uuid>/features/
§Errors
Returns Err if reading the features directory fails.
Sourcepub fn generation(&self) -> Result<u64>
pub fn generation(&self) -> Result<u64>
Current filesystem generation number.
/sys/fs/btrfs/<uuid>/generation
§Errors
Returns Err if the sysfs file cannot be read or parsed.
Sourcepub fn label(&self) -> Result<String>
pub fn label(&self) -> Result<String>
Filesystem label. Empty string if no label is set.
/sys/fs/btrfs/<uuid>/label
§Errors
Returns Err if the sysfs file cannot be read.
Sourcepub fn metadata_uuid(&self) -> Result<Uuid>
pub fn metadata_uuid(&self) -> Result<Uuid>
Metadata UUID. May differ from the filesystem UUID if the metadata UUID
feature is in use.
/sys/fs/btrfs/<uuid>/metadata_uuid
§Errors
Returns Err if the sysfs file cannot be read or parsed.
Sourcepub fn nodesize(&self) -> Result<u64>
pub fn nodesize(&self) -> Result<u64>
B-tree node size in bytes.
/sys/fs/btrfs/<uuid>/nodesize
§Errors
Returns Err if the sysfs file cannot be read or parsed.
Sourcepub fn quota_override(&self) -> Result<bool>
pub fn quota_override(&self) -> Result<bool>
Whether the quota override is active.
/sys/fs/btrfs/<uuid>/quota_override
§Errors
Returns Err if the sysfs file cannot be read or parsed.
Sourcepub fn read_policy(&self) -> Result<String>
pub fn read_policy(&self) -> Result<String>
Read policy for RAID profiles, e.g. "[pid]" or "[roundrobin]".
/sys/fs/btrfs/<uuid>/read_policy
§Errors
Returns Err if the sysfs file cannot be read.
Sourcepub fn sectorsize(&self) -> Result<u64>
pub fn sectorsize(&self) -> Result<u64>
Sector size in bytes.
/sys/fs/btrfs/<uuid>/sectorsize
§Errors
Returns Err if the sysfs file cannot be read or parsed.
Sourcepub fn temp_fsid(&self) -> Result<bool>
pub fn temp_fsid(&self) -> Result<bool>
Whether a temporary fsid is in use (seeding device feature).
/sys/fs/btrfs/<uuid>/temp_fsid
§Errors
Returns Err if the sysfs file cannot be read or parsed.
Sourcepub fn scrub_speed_max_get(&self, devid: u64) -> Result<u64>
pub fn scrub_speed_max_get(&self, devid: u64) -> Result<u64>
Read the per-device scrub throughput limit for the given device, in
bytes per second. A value of 0 means no limit is set (unlimited).
/sys/fs/btrfs/<uuid>/devinfo/<devid>/scrub_speed_max
§Errors
Returns Err if the sysfs file cannot be read or parsed.
Sourcepub fn scrub_speed_max_set(&self, devid: u64, limit: u64) -> Result<()>
pub fn scrub_speed_max_set(&self, devid: u64, limit: u64) -> Result<()>
Set the per-device scrub throughput limit for the given device, in
bytes per second. Pass 0 to remove the limit (unlimited).
Requires root.
/sys/fs/btrfs/<uuid>/devinfo/<devid>/scrub_speed_max
§Errors
Returns Err if the write fails.
Sourcepub fn send_stream_version(&self) -> u32
pub fn send_stream_version(&self) -> u32
Maximum send stream protocol version supported by the kernel.
Returns 1 if the sysfs file does not exist (older kernels without
versioned send stream support).
/sys/fs/btrfs/features/send_stream_version
Sourcepub fn quota_status(&self) -> Result<QuotaStatus>
pub fn quota_status(&self) -> Result<QuotaStatus>
Quota status for this filesystem, read from
/sys/fs/btrfs/<uuid>/qgroups/.
Returns Ok(QuotaStatus { enabled: false, .. }) when quota is not
enabled (the qgroups/ directory does not exist). Returns an
io::Error with kind NotFound if the sysfs entry for this UUID
does not exist (i.e. the filesystem is not currently mounted).
§Errors
Returns Err if the sysfs files cannot be read or parsed.