Skip to content

Commit

Permalink
sysfs: keep a non-decodable sysfs attribute as unmodified bytes
Browse files Browse the repository at this point in the history
This was causing some issues with vpd pg83 reading on newer mpt3sas
drivers.
thiell committed Nov 15, 2021
1 parent 875175c commit 567be94
Showing 2 changed files with 8 additions and 4 deletions.
6 changes: 5 additions & 1 deletion sasutils/cli/sas_devices.py
Original file line number Diff line number Diff line change
@@ -156,7 +156,11 @@ def print_end_devices(self, sysfsnode):
for scsi_device in sas_end_device.targets:
if scsi_device.block:
try:
pg83 = bytes(scsi_device.attrs.vpd_pg83)
try:
pg83 = bytes(scsi_device.attrs.vpd_pg83)
except TypeError:
pg83 = bytes(scsi_device.attrs.vpd_pg83,
encoding='utf-8')
lu = vpd_decode_pg83_lu(pg83)
except (AttributeError, struct.error):
lu = vpd_get_page83_lu(scsi_device.block.name)
6 changes: 3 additions & 3 deletions sasutils/sysfs.py
Original file line number Diff line number Diff line change
@@ -80,11 +80,11 @@ def iterget(self, pathname, ignore_errors, absolute=False):
if isfile(path) and access(path, R_OK):
try:
with open(path, 'rb') as fp:
data = fp.read().strip()
data = fp.read()
try:
data = data.decode("utf-8", errors='backslashreplace')
data = data.decode("utf-8").strip()
except UnicodeDecodeError:
pass
data = data
yield data
except IOError as exc:
if not ignore_errors:

0 comments on commit 567be94

Please sign in to comment.