tools/osbuild-image-info: skip swap partitions

When iterating partitions to mount, skip any with filesystem type
"swap".  This is done in two places:
1. When mounting partitions to find /etc/fstab.
2. When mounting partitions and volumes to analyse the tree.
This commit is contained in:
Achilleas Koutsou 2025-01-06 20:16:19 +01:00 committed by Tomáš Hozza
parent b9e84587ad
commit dc047513b7

View file

@ -2623,6 +2623,8 @@ def append_partitions(report, image):
# find partition with fstab and read it
fstab = []
for fs in filesystems.values():
if fs["type"] == "swap":
continue
dev, opts = fs["device"], fs.get("mntops")
with mount(dev, opts) as tree:
if os.path.exists(f"{tree}/etc/fstab"):
@ -2650,6 +2652,9 @@ def append_partitions(report, image):
info = index.get_module_info("Mount", "org.osbuild.btrfs")
elif "xfs" in part_fstype:
info = index.get_module_info("Mount", "org.osbuild.xfs")
elif "swap" in part_fstype:
# can't mount swap partitions
continue
else:
raise RuntimeError(f"Unknown file system: {part_fstype}")
if not info: