Skip to content

Commit

Permalink
storage: rely on devpath to determine size, not devname
Browse files Browse the repository at this point in the history
This also enabled logging so we can figure out whether the directory or
the file does not exist.

Signed-off-by: Olivier Gayot <[email protected]>
  • Loading branch information
ogayot committed Apr 25, 2024
1 parent 34282e4 commit ed130f6
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions probert/storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit ed130f6

Please sign in to comment.