image-info: read sector size, if available

Use the sector size reported by 'sfdisk', if available, otherwise
default to the standard value of '512' (as currently assumed).
This commit is contained in:
Christian Kellner 2020-07-08 17:43:35 +02:00 committed by Ondřej Budai
parent 5bca8bcacd
commit aa03f1617a

View file

@ -171,6 +171,7 @@ def read_partition_table(device):
ptable = sfdisk["partitiontable"]
assert ptable["unit"] == "sectors"
is_dos = ptable["label"] == "dos"
ssize = ptable.get("sectorsize", 512)
for i, p in enumerate(ptable["partitions"]):
@ -187,8 +188,8 @@ def read_partition_table(device):
partitions.append({
"bootable": p.get("bootable", False),
"type": p["type"],
"start": p["start"] * 512,
"size": p["size"] * 512,
"start": p["start"] * ssize,
"size": p["size"] * ssize,
"partuuid": partuuid
})