Handle BTRFS Subvolumes properly, fixes #1
This commit is contained in:
parent
3358c807a0
commit
4b6a059f1d
1 changed files with 10 additions and 2 deletions
|
@ -546,10 +546,12 @@ class StatsPart(Part):
|
||||||
# mountpoints
|
# mountpoints
|
||||||
names = []
|
names = []
|
||||||
first_mountpoint = True
|
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:
|
with open("/proc/self/mounts") as f:
|
||||||
for line in f:
|
for line in f:
|
||||||
_, dir, type, options, *rest = line.split()
|
device, dir, type, options, *rest = line.split()
|
||||||
|
|
||||||
# skip non-storage mounts
|
# skip non-storage mounts
|
||||||
if type in MOUNT_IGNORE_FS:
|
if type in MOUNT_IGNORE_FS:
|
||||||
|
@ -577,8 +579,14 @@ class StatsPart(Part):
|
||||||
else:
|
else:
|
||||||
short_name = " /"
|
short_name = " /"
|
||||||
|
|
||||||
# handle btrfs separately
|
# handle btrfs subvolumes
|
||||||
if type == "btrfs":
|
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])
|
btrfs_raw = command(["/sbin/btrfs", "fi", "usage", "-b", dir])
|
||||||
|
|
||||||
for line in btrfs_raw.split("\n"):
|
for line in btrfs_raw.split("\n"):
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue