diff options
author | David Teigland <teigland@redhat.com> | 2022-02-22 15:03:11 -0600 |
---|---|---|
committer | David Teigland <teigland@redhat.com> | 2022-02-24 15:37:53 -0600 |
commit | 07338325e552bb692f2422f42750e70c9d31152c (patch) | |
tree | 46016e2027141fa85b7e5aae58c1ce6c14bb41b3 /lib/activate/dev_manager.c | |
parent | ac1f4bbbfd4c5f1387c3e0607f7d556409e7a4b4 (diff) | |
download | lvm2-dev-dct-devs3.tar.gz |
devices: fix name handlingdev-dct-devs3
- Fix cases where incorrect device paths were left
on the dev->aliases list. Leaving incorrect paths
on dev->aliases could result in using the wrong device.
- Fix a widespread incorrect assumption that dev_name()
always returns a valid path (or NULL). dev_name()
returns "[unknown]" when there are no paths to a
device, and is mainly meant to be used in messages.
- Check for valid dev paths in cases that want to use
the from dev_name() for things other than a message.
Diffstat (limited to 'lib/activate/dev_manager.c')
-rw-r--r-- | lib/activate/dev_manager.c | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/lib/activate/dev_manager.c b/lib/activate/dev_manager.c index 63bfd9b74..2cae3bed1 100644 --- a/lib/activate/dev_manager.c +++ b/lib/activate/dev_manager.c @@ -2947,6 +2947,10 @@ int add_areas_line(struct dev_manager *dm, struct lv_segment *seg, /* FIXME Avoid repeating identical stat in dm_tree_node_add_target_area */ for (s = start_area; s < areas; s++) { + + /* FIXME: dev_name() does not return NULL! It needs to check if dm_list_empty(&dev->aliases) + but this knot of logic is too complex to pull apart without careful deconstruction. */ + if ((seg_type(seg, s) == AREA_PV && (!seg_pvseg(seg, s) || !seg_pv(seg, s) || !seg_dev(seg, s) || !(name = dev_name(seg_dev(seg, s))) || !*name || @@ -2965,7 +2969,10 @@ int add_areas_line(struct dev_manager *dm, struct lv_segment *seg, return_0; num_error_areas++; } else if (seg_type(seg, s) == AREA_PV) { - if (!dm_tree_node_add_target_area(node, dev_name(seg_dev(seg, s)), NULL, + struct device *dev = seg_dev(seg, s); + name = dm_list_empty(&dev->aliases) ? NULL : dev_name(dev); + + if (!dm_tree_node_add_target_area(node, name, NULL, (seg_pv(seg, s)->pe_start + (extent_size * seg_pe(seg, s))))) return_0; num_existing_areas++; |