From d456397af72545abf6493d4290d56646c814e5bc Mon Sep 17 00:00:00 2001 From: =?utf8?q?=C5=81ukasz=20Stelmach?= Date: Thu, 13 Jun 2024 13:12:41 +0200 Subject: [PATCH] scripts: sd_fusing: support device symlinks in ensure_parttable() MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit sd_fusing needs to support referring to devices by symlinks created by udev like /dev/disk/by-id/usb-Generic_STORAGE_DEVICE_000000000272-0. Their partitions are named /dev/disk/by-id/usb-Generic_STORAGE_DEVICE_000000000272-0-partX. Therefore there is no universal way to access both /dev/sdXY and the symlinked partitions and using get_partition_device() is the way to go. Change-Id: I4c586f8e9b6e3940faa6055c90835bbff1777ec5 Fixes: 43ab41c7e7 ("sd_fusing.py: Ensure selected flashing target actually matches what is on device") Signed-off-by: Łukasz Stelmach --- sd_fusing.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/sd_fusing.py b/sd_fusing.py index 8f57d15..1996250 100755 --- a/sd_fusing.py +++ b/sd_fusing.py @@ -15,7 +15,7 @@ import sys import tarfile import tempfile -__version__ = "1.1.2" +__version__ = "1.1.3" Format = False Device = "" @@ -179,7 +179,8 @@ class SdFusingTarget: def ensure_parttable(self): logging.notice(f"Verifying that partition table on {Device} matches target specification") for partnum, part in enumerate(self.part_table, 1): - bo = subprocess.check_output(["blkid", "-o", "export", Device + str(partnum)]).decode('utf-8') + d = "/dev/" + get_partition_device(Device, partnum) + bo = subprocess.check_output(["blkid", "-o", "export", d]).decode('utf-8') if "PARTLABEL=" in bo and f"PARTLABEL={part['name']}" not in bo: logging.error(f'On-device partition label mismatch with selected target: partlabel={part["name"]}, on-device:\n{bo}') sys.exit(1) -- 2.34.1