Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnton Hvornum <anton@hvornum.se>2021-04-09 11:53:54 +0200
committerAnton Hvornum <anton@hvornum.se>2021-04-09 11:53:54 +0200
commiteb0ae8b1c35e421f88b7eabcc445d1069969ba76 (patch)
tree43edb7999ab30a8b45babf753aafd203e2b8be20
parent1395f0888c52f01a231aec6c437d570895a03210 (diff)
Added disk helper function get_partitions_in_use(). Which returns which partions are being used at a given mount location, including children.
-rw-r--r--archinstall/lib/disk.py18
-rw-r--r--archinstall/lib/installer.py1
2 files changed, 19 insertions, 0 deletions
diff --git a/archinstall/lib/disk.py b/archinstall/lib/disk.py
index f0fe7181..af40e36f 100644
--- a/archinstall/lib/disk.py
+++ b/archinstall/lib/disk.py
@@ -574,6 +574,24 @@ def get_mount_info(path):
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):
try:
handle = sys_command(f"blkid -o value -s TYPE {path}")
diff --git a/archinstall/lib/installer.py b/archinstall/lib/installer.py
index 11f75f99..d17ee77c 100644
--- a/archinstall/lib/installer.py
+++ b/archinstall/lib/installer.py
@@ -49,6 +49,7 @@ class Installer():
storage['session'] = self
self.partitions = get_partitions_in_use(self.target)
+ print(self.partitions)
def log(self, *args, level=LOG_LEVELS.Debug, **kwargs):
"""