There have been two methods used for this in the past: regex substition and sysfs path traversal. Both have fatal flaws. This method's only vulnerability is udev ceasing to provide the required data item.
There's an updates image out for testing in the bug (1190886), but I'm fairly confident already because this patch has been on my uevents- branch for a while now. I had issues with the patch from 1181336 when I was testing using disk images (which use partitioned dm devices), and I believe they're seeing the same in 1190886.
Resolves: rhbz#1190886 Related: rhbz#1181336 --- blivet/udev.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-)
diff --git a/blivet/udev.py b/blivet/udev.py index 7ae42b1..aefa631 100644 --- a/blivet/udev.py +++ b/blivet/udev.py @@ -580,7 +580,19 @@ def device_is_biosraid_member(info): return False
def device_get_dm_partition_disk(info): - return os.path.basename(os.path.dirname(device_get_sysfs_path(info))) + if not device_is_dm_partition(info): + return None + + disk = None + majorminor = info["ID_PART_ENTRY_DISK"] + if majorminor: + major, minor = majorminor.split(":") + for device in get_devices(): + if device.get("MAJOR") == major and device.get("MINOR") == minor: + disk = device_get_name(device) + break + + return disk
def device_is_dm_partition(info): return (device_is_dm(info) and
On Tue, 2015-02-17 at 08:59 -0600, David Lehman wrote:
Resolves: rhbz#1190886 Related: rhbz#1181336
blivet/udev.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-)
diff --git a/blivet/udev.py b/blivet/udev.py index 7ae42b1..aefa631 100644 --- a/blivet/udev.py +++ b/blivet/udev.py @@ -580,7 +580,19 @@ def device_is_biosraid_member(info): return False
def device_get_dm_partition_disk(info):
- return os.path.basename(os.path.dirname(device_get_sysfs_path(info)))
- if not device_is_dm_partition(info):
return None
- disk = None
- majorminor = info["ID_PART_ENTRY_DISK"]
- if majorminor:
major, minor = majorminor.split(":")
for device in get_devices():
if device.get("MAJOR") == major and device.get("MINOR") == minor:
disk = device_get_name(device)
break
- return disk
def device_is_dm_partition(info): return (device_is_dm(info) and
Looks good to me.
anaconda-patches@lists.fedorahosted.org