From ed130f63e83a1504fd82a5cb4d2c00fe28e8da8f Mon Sep 17 00:00:00 2001 From: Olivier Gayot Date: Thu, 25 Apr 2024 11:32:31 +0200 Subject: [PATCH] storage: rely on devpath to determine size, not devname This also enabled logging so we can figure out whether the directory or the file does not exist. Signed-off-by: Olivier Gayot --- probert/storage.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/probert/storage.py b/probert/storage.py index 453ddac..27ad6b8 100644 --- a/probert/storage.py +++ b/probert/storage.py @@ -21,7 +21,7 @@ import subprocess from probert.utils import ( - read_sys_block_size_bytes, + read_sys_devpath_size_bytes, sane_block_devices, udev_get_attributes, ) @@ -135,11 +135,12 @@ def _extract_partition_table(devname): blockdev = {} for device in interesting_storage_devs(context): devname = device.properties['DEVNAME'] + devpath = device.properties['DEVPATH'] attrs = udev_get_attributes(device) # update the size attr as it may only be the number # of blocks rather than size in bytes. - attrs['size'] = \ - str(read_sys_block_size_bytes(devname)) + attrs['size'] = str(read_sys_devpath_size_bytes( + devpath, log_inexistent=True)) # When dereferencing device[prop], pyudev calls bytes.decode(), which # can fail if the value is invalid utf-8. We don't want a single # invalid value to completely prevent probing. So we iterate