Added disk helper function get_partitions_in_use(). Which returns which partions are being used at a given mount location, including children.
This commit is contained in:
parent
1395f0888c
commit
eb0ae8b1c3
|
|
@ -574,6 +574,24 @@ def get_mount_info(path):
|
||||||
|
|
||||||
return output['filesystems'][0]
|
return output['filesystems'][0]
|
||||||
|
|
||||||
|
def get_partitions_in_use(mountpoint):
|
||||||
|
try:
|
||||||
|
output = b''.join(sys_command(f'/usr/bin/findmnt --json -R {path}'))
|
||||||
|
except SysCallError:
|
||||||
|
return {}
|
||||||
|
|
||||||
|
mounts = []
|
||||||
|
|
||||||
|
output = output.decode('UTF-8')
|
||||||
|
output = json.loads(output)
|
||||||
|
for target in output.get('filesystems', []):
|
||||||
|
mounts.append(Partition(target['source'], filesystem=target.get('fstype', None), mountpoint=target['target']))
|
||||||
|
|
||||||
|
for child in target.get('children', []):
|
||||||
|
mounts.append(Partition(child['source'], filesystem=child.get('fstype', None), mountpoint=child['target']))
|
||||||
|
|
||||||
|
return mounts
|
||||||
|
|
||||||
def get_filesystem_type(path):
|
def get_filesystem_type(path):
|
||||||
try:
|
try:
|
||||||
handle = sys_command(f"blkid -o value -s TYPE {path}")
|
handle = sys_command(f"blkid -o value -s TYPE {path}")
|
||||||
|
|
|
||||||
|
|
@ -49,6 +49,7 @@ class Installer():
|
||||||
|
|
||||||
storage['session'] = self
|
storage['session'] = self
|
||||||
self.partitions = get_partitions_in_use(self.target)
|
self.partitions = get_partitions_in_use(self.target)
|
||||||
|
print(self.partitions)
|
||||||
|
|
||||||
def log(self, *args, level=LOG_LEVELS.Debug, **kwargs):
|
def log(self, *args, level=LOG_LEVELS.Debug, **kwargs):
|
||||||
"""
|
"""
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue