added support for btrfs free space readout
This commit is contained in:
parent
22600d3b31
commit
79b47e1130
1 changed files with 23 additions and 8 deletions
|
@ -313,7 +313,10 @@ def command(cmd):
|
||||||
Executes a command, returns stdout, suppresses stderr."
|
Executes a command, returns stdout, suppresses stderr."
|
||||||
"""
|
"""
|
||||||
|
|
||||||
s = subprocess.Popen(cmd.split(), stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
if type(cmd) == str:
|
||||||
|
cmd = cmd.split()
|
||||||
|
|
||||||
|
s = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||||
s.wait()
|
s.wait()
|
||||||
|
|
||||||
return s.stdout.read().decode("utf-8")
|
return s.stdout.read().decode("utf-8")
|
||||||
|
@ -549,7 +552,7 @@ class StatsPart(Part):
|
||||||
if "rw" not in options.split(","):
|
if "rw" not in options.split(","):
|
||||||
continue
|
continue
|
||||||
|
|
||||||
# /proc/self/mounts uses a literal \\040 string to escape spaces
|
# /proc/self/mounts uses a literal \040 string to escape spaces
|
||||||
dir = dir.replace("\\040", " ")
|
dir = dir.replace("\\040", " ")
|
||||||
|
|
||||||
basename = os.path.basename(dir)
|
basename = os.path.basename(dir)
|
||||||
|
@ -565,6 +568,18 @@ class StatsPart(Part):
|
||||||
else:
|
else:
|
||||||
short_name = " /"
|
short_name = " /"
|
||||||
|
|
||||||
|
# handle btrfs separately
|
||||||
|
if type == "btrfs":
|
||||||
|
btrfs_raw = command(["/sbin/btrfs", "fi", "usage", "-b", dir])
|
||||||
|
|
||||||
|
for line in btrfs_raw.split("\n"):
|
||||||
|
if "Device size" in line:
|
||||||
|
stor_total = int(line.split()[-1])
|
||||||
|
elif "Free" in line:
|
||||||
|
stor_free = int(line.split()[-3])
|
||||||
|
break
|
||||||
|
|
||||||
|
else:
|
||||||
try:
|
try:
|
||||||
stat = os.statvfs(dir)
|
stat = os.statvfs(dir)
|
||||||
except PermissionError:
|
except PermissionError:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue