diff --git a/libexec/render.py b/libexec/render.py index f9714eb..8eb3642 100755 --- a/libexec/render.py +++ b/libexec/render.py @@ -546,10 +546,12 @@ class StatsPart(Part): # mountpoints names = [] first_mountpoint = True + btrfs_encountered_devices = set() + device_to_label = {os.path.join("/dev", os.path.basename(os.readlink(os.path.join("/dev/disk/by-label", x)))): x for x in os.listdir("/dev/disk/by-label")} with open("/proc/self/mounts") as f: for line in f: - _, dir, type, options, *rest = line.split() + device, dir, type, options, *rest = line.split() # skip non-storage mounts if type in MOUNT_IGNORE_FS: @@ -577,8 +579,14 @@ class StatsPart(Part): else: short_name = " /" - # handle btrfs separately + # handle btrfs subvolumes if type == "btrfs": + if device in btrfs_encountered_devices: + continue + + btrfs_encountered_devices.add(device) + short_name = " "+device_to_label[device][0] + btrfs_raw = command(["/sbin/btrfs", "fi", "usage", "-b", dir]) for line in btrfs_raw.split("\n"):