diff --git a/0003-Fix-resolving-devices-with-names-that-look-like-BIOS.patch b/0003-Fix-resolving-devices-with-names-that-look-like-BIOS.patch new file mode 100644 index 0000000..a1359ce --- /dev/null +++ b/0003-Fix-resolving-devices-with-names-that-look-like-BIOS.patch @@ -0,0 +1,75 @@ +From 3f27589b8f69a039521a0b2275527fe870567f2d Mon Sep 17 00:00:00 2001 +From: Vojtech Trefny +Date: Tue, 18 May 2021 12:54:02 +0200 +Subject: [PATCH] Fix resolving devices with names that look like BIOS drive + number + +A RAID array named "10" will not be resolved because we try to +resolve it using EDD data and after this lookup fails, we don't +try the name. + +Resolves: rhbz#1960798 +--- + blivet/devicetree.py | 18 +++++++++--------- + tests/devicetree_test.py | 4 ++++ + 2 files changed, 13 insertions(+), 9 deletions(-) + +diff --git a/blivet/devicetree.py b/blivet/devicetree.py +index 88e9f0e5..339a3cd2 100644 +--- a/blivet/devicetree.py ++++ b/blivet/devicetree.py +@@ -634,20 +634,20 @@ class DeviceTreeBase(object): + (label.startswith("'") and label.endswith("'"))): + label = label[1:-1] + device = self.labels.get(label) +- elif re.match(r'(0x)?[A-Fa-f0-9]{2}(p\d+)?$', devspec): +- # BIOS drive number +- (drive, _p, partnum) = devspec.partition("p") +- spec = int(drive, 16) +- for (edd_name, edd_number) in self.edd_dict.items(): +- if edd_number == spec: +- device = self.get_device_by_name(edd_name + partnum) +- break + elif options and "nodev" in options.split(","): + device = self.get_device_by_name(devspec) + if not device: + device = self.get_device_by_path(devspec) + else: +- if not devspec.startswith("/dev/"): ++ if re.match(r'(0x)?[A-Fa-f0-9]{2}(p\d+)?$', devspec): ++ # BIOS drive number ++ (drive, _p, partnum) = devspec.partition("p") ++ spec = int(drive, 16) ++ for (edd_name, edd_number) in self.edd_dict.items(): ++ if edd_number == spec: ++ device = self.get_device_by_name(edd_name + partnum) ++ ++ if not device and not devspec.startswith("/dev/"): + device = self.get_device_by_name(devspec) + if not device: + devspec = "/dev/" + devspec +diff --git a/tests/devicetree_test.py b/tests/devicetree_test.py +index 11f8469d..b033343d 100644 +--- a/tests/devicetree_test.py ++++ b/tests/devicetree_test.py +@@ -49,6 +49,9 @@ class DeviceTreeTestCase(unittest.TestCase): + dev3 = StorageDevice("sdp2", exists=True) + dt._add_device(dev3) + ++ dev4 = StorageDevice("10", exists=True) ++ dt._add_device(dev4) ++ + dt.edd_dict.update({"dev1": 0x81, + "dev2": 0x82}) + +@@ -62,6 +65,7 @@ class DeviceTreeTestCase(unittest.TestCase): + self.assertEqual(dt.resolve_device("0x82"), dev2) + + self.assertEqual(dt.resolve_device(dev3.name), dev3) ++ self.assertEqual(dt.resolve_device(dev4.name), dev4) + + def test_device_name(self): + # check that devicetree.names property contains all device's names +-- +2.31.1 + diff --git a/python-blivet.spec b/python-blivet.spec index bc0f071..f337247 100644 --- a/python-blivet.spec +++ b/python-blivet.spec @@ -23,7 +23,7 @@ Version: 3.3.3 #%%global prerelease .b2 # prerelease, if defined, should be something like .a1, .b1, .b2.dev1, or .c2 -Release: 2%{?prerelease}%{?dist} +Release: 3%{?prerelease}%{?dist} Epoch: 1 License: LGPLv2+ %global realname blivet @@ -36,6 +36,7 @@ Patch0: 0001-remove-btrfs-plugin.patch %endif Patch1: 0002-Avoid-AttributeError-for-DiskLabel-formats-without-disklabel-type.patch +Patch2: 0003-Fix-resolving-devices-with-names-that-look-like-BIOS.patch # Versions of required components (done so we make sure the buildrequires # match the requires versions of things). @@ -198,6 +199,9 @@ configuration. %endif %changelog +* Tue Jun 29 2021 Vojtech Trefny - 3.3.3-3 +- Fix resolving devices with names that look like BIOS drive number (#1960798) + * Mon Apr 12 2021 Vojtech Trefny - 3.3.3-2 - Avoid AttributeError for DiskLabel formats without disklabel type (#1945914)