fix: inspect loop devices using explicit JSON list mode
This commit is contained in:
@@ -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')
|
||||
|
||||
Reference in New Issue
Block a user