mirror of
git://sourceware.org/git/lvm2.git
synced 2026-01-21 12:32:46 +03:00
dev_manager: check prohibited devices earlier
Reorder detection for internal device - since this test is much simpler then target analysis, check it sooner. Replace test for '68' with sizeof & ID_LEN Add FIXME about device alias problem with is_reserved_lvname, since this test fails on devices like /dev/dm-X so we need to convert tests to UUID.
This commit is contained in:
@@ -392,6 +392,27 @@ static int _device_is_usable(struct device *dev, int check_lv_names)
|
||||
goto out;
|
||||
}
|
||||
|
||||
/* Check internal lvm devices */
|
||||
if (check_lv_names &&
|
||||
uuid && !strncmp(uuid, UUID_PREFIX, sizeof(UUID_PREFIX) - 1)) {
|
||||
if (strlen(uuid) > (sizeof(UUID_PREFIX) + 2 * ID_LEN)) { /* 68 */
|
||||
log_debug_activation("%s: Reserved uuid %s on internal LV device %s not usable.",
|
||||
dev_name(dev), uuid, name);
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (!(vgname = dm_strdup(name)) ||
|
||||
!dm_split_lvm_name(NULL, NULL, &vgname, &lvname, &layer))
|
||||
goto_out;
|
||||
|
||||
/* FIXME: fails to handle dev aliases i.e. /dev/dm-5, replace with UUID suffix */
|
||||
if (lvname && (is_reserved_lvname(lvname) || *layer)) {
|
||||
log_debug_activation("%s: Reserved internal LV device %s/%s%s%s not usable.",
|
||||
dev_name(dev), vgname, lvname, *layer ? "-" : "", layer);
|
||||
goto out;
|
||||
}
|
||||
}
|
||||
|
||||
/* FIXME Also check for mpath no paths */
|
||||
do {
|
||||
next = dm_get_next_target(dmt, next, &start, &length,
|
||||
@@ -439,26 +460,6 @@ static int _device_is_usable(struct device *dev, int check_lv_names)
|
||||
|
||||
/* FIXME Also check dependencies? */
|
||||
|
||||
/* Check internal lvm devices */
|
||||
if (check_lv_names &&
|
||||
uuid && !strncmp(uuid, UUID_PREFIX, sizeof(UUID_PREFIX) - 1)) {
|
||||
if (!(vgname = dm_strdup(name)) ||
|
||||
!dm_split_lvm_name(NULL, NULL, &vgname, &lvname, &layer))
|
||||
goto_out;
|
||||
|
||||
if (strlen(uuid) > 68) {
|
||||
log_debug_activation("%s: Reserved uuid %s on internal LV device %s/%s%s%s not usable.",
|
||||
dev_name(dev), uuid, vgname, lvname, *layer ? "-" : "", layer);
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (lvname && (is_reserved_lvname(lvname) || *layer)) {
|
||||
log_debug_activation("%s: Reserved internal LV device %s/%s%s%s not usable.",
|
||||
dev_name(dev), vgname, lvname, *layer ? "-" : "", layer);
|
||||
goto out;
|
||||
}
|
||||
}
|
||||
|
||||
r = 1;
|
||||
|
||||
out:
|
||||
|
||||
Reference in New Issue
Block a user