mirror of
git://sourceware.org/git/lvm2.git
synced 2025-03-10 16:58:47 +03:00
lvconvert: improve vg parameter parsing
Commit abd9618dd8b77ca1974074ae76fa6a08f1a687d9 tried to improve parsing of vg name from logical path - but still missed couple corner cases. This patch further improves the logic and reuses validate_lvname_param() for parsing of lv_name. Also explicitly checks for LVM_VG_NAME in the right case. So now also properly parses cases like: 'lvconvert --repairt vg/' and will provide correct error message.
This commit is contained in:
parent
5c415afd85
commit
70cbd8f1a5
@ -1,5 +1,6 @@
|
|||||||
Version 2.02.146 -
|
Version 2.02.146 -
|
||||||
=================================
|
=================================
|
||||||
|
Another attempt to improve VG name parsing for lvconvert (2.02.144).
|
||||||
Use new cache status info and skip flushing for failed cache.
|
Use new cache status info and skip flushing for failed cache.
|
||||||
Support --uncache with missing PVs.
|
Support --uncache with missing PVs.
|
||||||
Tidy report field names, headings and widths.
|
Tidy report field names, headings and widths.
|
||||||
|
@ -115,9 +115,6 @@ static int _lvconvert_name_params(struct lvconvert_params *lp,
|
|||||||
struct cmd_context *cmd,
|
struct cmd_context *cmd,
|
||||||
int *pargc, char ***pargv)
|
int *pargc, char ***pargv)
|
||||||
{
|
{
|
||||||
char *ptr;
|
|
||||||
const char *vg_name = NULL;
|
|
||||||
|
|
||||||
if (lp->merge) {
|
if (lp->merge) {
|
||||||
if (!*pargc) {
|
if (!*pargc) {
|
||||||
log_error("Please specify a logical volume path.");
|
log_error("Please specify a logical volume path.");
|
||||||
@ -174,26 +171,24 @@ static int _lvconvert_name_params(struct lvconvert_params *lp,
|
|||||||
if (!validate_restricted_lvname_param(cmd, &lp->vg_name, &lp->lv_split_name))
|
if (!validate_restricted_lvname_param(cmd, &lp->vg_name, &lp->lv_split_name))
|
||||||
return_0;
|
return_0;
|
||||||
|
|
||||||
if ((vg_name = extract_vgname(cmd, lp->lv_name_full)) &&
|
if (!lp->vg_name && !strchr(lp->lv_name_full, '/')) {
|
||||||
lp->vg_name && strcmp(vg_name, lp->vg_name)) {
|
/* Check for $LVM_VG_NAME */
|
||||||
log_error("Please use a single volume group name "
|
if (!(lp->vg_name = extract_vgname(cmd, NULL))) {
|
||||||
"(\"%s\" or \"%s\")", vg_name, lp->vg_name);
|
log_error("Please specify a logical volume path.");
|
||||||
return 0;
|
return 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!lp->vg_name)
|
if (!validate_lvname_param(cmd, &lp->vg_name, &lp->lv_name_full))
|
||||||
lp->vg_name = vg_name;
|
return_0;
|
||||||
|
|
||||||
|
lp->lv_name = lp->lv_name_full;
|
||||||
|
|
||||||
if (!validate_name(lp->vg_name)) {
|
if (!validate_name(lp->vg_name)) {
|
||||||
log_error("Please provide a valid volume group name");
|
log_error("Please provide a valid volume group name");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((ptr = strrchr(lp->lv_name_full, '/')))
|
|
||||||
lp->lv_name = ptr + 1;
|
|
||||||
else
|
|
||||||
lp->lv_name = lp->lv_name_full;
|
|
||||||
|
|
||||||
if (!lp->merge_mirror &&
|
if (!lp->merge_mirror &&
|
||||||
!lp->repair &&
|
!lp->repair &&
|
||||||
!arg_count(cmd, splitmirrors_ARG) &&
|
!arg_count(cmd, splitmirrors_ARG) &&
|
||||||
|
Loading…
x
Reference in New Issue
Block a user