mirror of
git://sourceware.org/git/lvm2.git
synced 2024-12-21 13:34:40 +03:00
lvconvert: improve vg parameter parsing
Commit abd9618dd8
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 -
|
||||
=================================
|
||||
Another attempt to improve VG name parsing for lvconvert (2.02.144).
|
||||
Use new cache status info and skip flushing for failed cache.
|
||||
Support --uncache with missing PVs.
|
||||
Tidy report field names, headings and widths.
|
||||
|
@ -115,9 +115,6 @@ static int _lvconvert_name_params(struct lvconvert_params *lp,
|
||||
struct cmd_context *cmd,
|
||||
int *pargc, char ***pargv)
|
||||
{
|
||||
char *ptr;
|
||||
const char *vg_name = NULL;
|
||||
|
||||
if (lp->merge) {
|
||||
if (!*pargc) {
|
||||
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))
|
||||
return_0;
|
||||
|
||||
if ((vg_name = extract_vgname(cmd, lp->lv_name_full)) &&
|
||||
lp->vg_name && strcmp(vg_name, lp->vg_name)) {
|
||||
log_error("Please use a single volume group name "
|
||||
"(\"%s\" or \"%s\")", vg_name, lp->vg_name);
|
||||
if (!lp->vg_name && !strchr(lp->lv_name_full, '/')) {
|
||||
/* Check for $LVM_VG_NAME */
|
||||
if (!(lp->vg_name = extract_vgname(cmd, NULL))) {
|
||||
log_error("Please specify a logical volume path.");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (!lp->vg_name)
|
||||
lp->vg_name = vg_name;
|
||||
if (!validate_lvname_param(cmd, &lp->vg_name, &lp->lv_name_full))
|
||||
return_0;
|
||||
|
||||
lp->lv_name = lp->lv_name_full;
|
||||
|
||||
if (!validate_name(lp->vg_name)) {
|
||||
log_error("Please provide a valid volume group name");
|
||||
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 &&
|
||||
!lp->repair &&
|
||||
!arg_count(cmd, splitmirrors_ARG) &&
|
||||
|
Loading…
Reference in New Issue
Block a user