mirror of
git://sourceware.org/git/lvm2.git
synced 2025-01-03 05:18:29 +03:00
device_is_usable: minor improve
Replace allocated buffer with local vg_name which doesn't pass pointer to allocation. Join some conditions together.
This commit is contained in:
parent
0363e4de70
commit
4d75c4f597
@ -627,7 +627,8 @@ int device_is_usable(struct device *dev, struct dev_usable_check_params check, i
|
||||
const char *name, *uuid;
|
||||
uint64_t start, length;
|
||||
char *target_type = NULL;
|
||||
char *params, *vgname = NULL, *lvname, *layer;
|
||||
char *params, *vgname, *lvname, *layer;
|
||||
char vg_name[NAME_LEN];
|
||||
void *next = NULL;
|
||||
int only_error_target = 1;
|
||||
int r = 0;
|
||||
@ -652,16 +653,19 @@ int device_is_usable(struct device *dev, struct dev_usable_check_params check, i
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (uuid && (check.check_reserved || check.check_lv)) {
|
||||
if (!strncmp(uuid, UUID_PREFIX, sizeof(UUID_PREFIX) - 1)) { /* with LVM- prefix */
|
||||
if (check.check_reserved) {
|
||||
/* Check internal lvm devices */
|
||||
if (check.check_reserved &&
|
||||
uuid && !strncmp(uuid, UUID_PREFIX, sizeof(UUID_PREFIX) - 1)) {
|
||||
if (strlen(uuid) > (sizeof(UUID_PREFIX) + 2 * ID_LEN)) { /* 68 */
|
||||
if (strlen(uuid) > (sizeof(UUID_PREFIX) + 2 * ID_LEN)) { /* 68 with suffix */
|
||||
log_debug_activation("%s: Reserved uuid %s on internal LV device %s not usable.",
|
||||
dev_name(dev), uuid, name);
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (!(vgname = strdup(name)) ||
|
||||
/* Recognize some older reserved LVs just from the LV name (snapshot, pvmove...) */
|
||||
vgname = vg_name;
|
||||
if (!dm_strncpy(vg_name, name, sizeof(vg_name)) ||
|
||||
!dm_split_lvm_name(NULL, NULL, &vgname, &lvname, &layer))
|
||||
goto_out;
|
||||
|
||||
@ -673,14 +677,15 @@ int device_is_usable(struct device *dev, struct dev_usable_check_params check, i
|
||||
}
|
||||
}
|
||||
|
||||
if (check.check_lv && uuid && !strncmp(uuid, "LVM-", 4)) {
|
||||
if (check.check_lv) {
|
||||
/* Skip LVs */
|
||||
if (is_lv)
|
||||
*is_lv = 1;
|
||||
goto out;
|
||||
}
|
||||
}
|
||||
|
||||
if (check.check_reserved && uuid &&
|
||||
if (check.check_reserved &&
|
||||
(!strncmp(uuid, CRYPT_TEMP, sizeof(CRYPT_TEMP) - 1) ||
|
||||
!strncmp(uuid, CRYPT_SUBDEV, sizeof(CRYPT_SUBDEV) - 1) ||
|
||||
!strncmp(uuid, STRATIS, sizeof(STRATIS) - 1))) {
|
||||
@ -691,6 +696,7 @@ int device_is_usable(struct device *dev, struct dev_usable_check_params check, i
|
||||
name);
|
||||
goto out;
|
||||
}
|
||||
}
|
||||
|
||||
/* FIXME Also check for mpath no paths */
|
||||
do {
|
||||
@ -777,7 +783,6 @@ int device_is_usable(struct device *dev, struct dev_usable_check_params check, i
|
||||
r = 1;
|
||||
|
||||
out:
|
||||
free(vgname);
|
||||
dm_task_destroy(dmt);
|
||||
return r;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user