Skip to content

Commit 3fb1e17

Browse files
committed
osenum: Recognize partitions attached to a Linux install
This is the first step towards an "uninstall" option, but also useful for repair actions. Signed-off-by: Hector Martin <[email protected]>
1 parent e83274b commit 3fb1e17

2 files changed

Lines changed: 24 additions & 0 deletions

File tree

src/main.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -908,6 +908,7 @@ def main_loop(self):
908908
oses_upgradable = []
909909

910910
for i, p in enumerate(self.parts):
911+
p.index = i
911912
if p.type in ("Apple_APFS_ISC",):
912913
continue
913914
if p.free:
@@ -977,6 +978,8 @@ def main_loop(self):
977978
else:
978979
state += " "
979980
p_plain(f" OS: [{state}] {os}")
981+
if os.attached_partitions:
982+
p_plain(f" Extra partitions: {' '.join('#' + str(i.index) for i in os.attached_partitions)}")
980983
if os.stub and os.m1n1_ver and os.m1n1_ver != self.m1n1_ver:
981984
oses_upgradable.append((p, os))
982985
elif os.stub and not (os.bp and os.bp.get("coih", None)):

src/osenum.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ class OSInfo:
2727
bp: object = None
2828
paired: bool = False
2929
admin_users: object = None
30+
attached_partitions: list = None
3031

3132
def update_admin_users(self):
3233
try:
@@ -75,6 +76,26 @@ def collect(self, parts):
7576
else:
7677
self.collect_part(p)
7778

79+
for i, p in enumerate(parts):
80+
if len(p.os) != 1:
81+
continue
82+
os = p.os[0]
83+
if not os.stub:
84+
continue
85+
try:
86+
efi = parts[i + 1]
87+
except IndexError:
88+
continue
89+
90+
if efi.type != "EFI":
91+
continue
92+
os.attached_partitions = [efi]
93+
for j in range(i + 2, min(len(parts), i + 5)):
94+
q = parts[j]
95+
if q.type != "Linux Filesystem":
96+
continue
97+
os.attached_partitions.append(q)
98+
7899
def collect_recovery(self, part):
79100
logging.info(f"OSEnum.collect_recovery(part={part.name})")
80101
if part.container is None:

0 commit comments

Comments
 (0)