diff options
author | Dan Bungert <[email protected]> | 2024-07-12 12:46:09 -0600 |
---|---|---|
committer | Dan Bungert <[email protected]> | 2024-07-15 09:10:07 -0600 |
commit | c8009c5b2307d111e01fd85b0c468d495bbb5b35 (patch) | |
tree | 8a6b904dacd7940f0582e537c4dcaefe346bfe7d | |
parent | 810f63fd1670c70f4177014c80c165ae061b02aa (diff) |
block: fix partial sysfs partition read
If we have failed to populate this dict because a file is missing, there
is no sense attempting to read that value from the dict later.
The intention seems to be to skip partitions with missing data, so add
logging for that case.
LP: #2061073
-rw-r--r-- | curtin/block/__init__.py | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/curtin/block/__init__.py b/curtin/block/__init__.py index 921e1929..0de202ab 100644 --- a/curtin/block/__init__.py +++ b/curtin/block/__init__.py @@ -1000,21 +1000,28 @@ def sysfs_partition_data(blockdev=None, sysfs_path=None): sysfs_prefix = sys_block_path(parent) partnum = int(partnum) + keys = {'partition', 'start', 'size'} ptdata = [] for part_sysfs in get_sysfs_partitions(sysfs_prefix): data = {} - for sfile in ('partition', 'start', 'size'): + for sfile in keys: dfile = os.path.join(part_sysfs, sfile) if not os.path.isfile(dfile): continue data[sfile] = int(util.load_file(dfile)) if partnum is None or data['partition'] == partnum: - ptdata.append(( - path_to_kname(part_sysfs), - data['partition'], - data['start'] * SECTOR_SIZE_BYTES, - data['size'] * SECTOR_SIZE_BYTES, - )) + if data.keys() == keys: + ptdata.append(( + path_to_kname(part_sysfs), + data['partition'], + data['start'] * SECTOR_SIZE_BYTES, + data['size'] * SECTOR_SIZE_BYTES, + )) + else: + LOG.debug( + "sysfs_partition_data: " + f"skipping {part_sysfs} - incomplete sysfs read" + ) return ptdata |