fix: inspect loop devices using explicit JSON list mode

This commit is contained in:
Codex
2026-10-16 13:05:18 +08:00
parent 38201492af
commit e73af776ff
+1 -1
View File
@@ -32,7 +32,7 @@ def main():
if any(MOUNT.iterdir()): raise SystemExit('Mount point is not empty; original files preserved')
subprocess.run(['mount','-o','loop,nodev,nosuid,noexec',str(IMAGE),str(MOUNT)],check=True)
info=json.loads(subprocess.check_output(['findmnt','--json','--target',str(MOUNT)],text=True))['filesystems'][0]
loops=json.loads(subprocess.check_output(['losetup','--json','-j',str(IMAGE)],text=True))['loopdevices']
loops=json.loads(subprocess.check_output(['losetup','--list','--json','--associated',str(IMAGE)],text=True))['loopdevices']
if info['target']!=str(MOUNT) or info['fstype']!='ext4' or info['source'] not in [x['name'] for x in loops]:
raise SystemExit('Mount does not refer to the expected spool image')
if shutil.disk_usage(MOUNT).total > SIZE: raise SystemExit('Spool exceeds its hard limit')