Skip to main content

mounts_for_device

Function mounts_for_device 

Source
fn mounts_for_device(device_name: &str) -> Vec<DiskMountMetrics>
Expand description

Read /proc/mounts and return filesystem space for all mount points whose source device path starts with /dev/<device_name> (covers partitions too).

Three filters/guards mirror the Python implementation and prevent inflation:

  1. Mount points under /proc, /sys, /dev, /run are skipped — these are virtual hierarchies and frequent bind-mount targets.
  2. Each unique source path (e.g. /dev/sda1) is counted only once. The same source can appear at multiple mount points via bind mounts or btrfs subvolumes; without deduplication, statvfs returns the same pool size for each entry, multiplying the reported total by the subvolume count.
  3. Pseudo-filesystems with f_blocks == 0 are skipped after statvfs.