mirror of
git://sourceware.org/git/lvm2.git
synced 2025-02-25 21:57:45 +03:00
cleanup: postpone confirmation prompt for snapshot
Prompt user for confimation after more checks are done. (So we avoid case prompting and failing after prompt)
This commit is contained in:
parent
ba7796e055
commit
6872adc0ff
@ -964,26 +964,6 @@ static int _lvchange_single(struct cmd_context *cmd, struct logical_volume *lv,
|
||||
return ECMD_FAILED;
|
||||
}
|
||||
|
||||
if (lv_is_cow(lv) && !lv_is_virtual_origin(origin = origin_from_cow(lv)) &&
|
||||
arg_count(cmd, activate_ARG)) {
|
||||
if (origin->origin_count < 2)
|
||||
snaps_msg[0] = '\0';
|
||||
else if (dm_snprintf(snaps_msg, sizeof(snaps_msg),
|
||||
" and %u other snapshot(s)",
|
||||
origin->origin_count - 1) < 0) {
|
||||
log_error("Failed to prepare message.");
|
||||
return ECMD_FAILED;
|
||||
}
|
||||
|
||||
if (!arg_count(cmd, yes_ARG) &&
|
||||
(yes_no_prompt("Change of snapshot %s will also change its"
|
||||
" origin %s%s. Proceed? [y/n]: ", lv->name,
|
||||
origin->name, snaps_msg) == 'n')) {
|
||||
log_error("Logical volume %s not changed.", lv->name);
|
||||
return ECMD_FAILED;
|
||||
}
|
||||
}
|
||||
|
||||
if (lv->status & PVMOVE) {
|
||||
log_error("Unable to change pvmove LV %s", lv->name);
|
||||
if (arg_count(cmd, activate_ARG))
|
||||
@ -1019,6 +999,25 @@ static int _lvchange_single(struct cmd_context *cmd, struct logical_volume *lv,
|
||||
return ECMD_FAILED;
|
||||
}
|
||||
|
||||
if (lv_is_cow(lv) && arg_count(cmd, activate_ARG)) {
|
||||
if (origin->origin_count < 2)
|
||||
snaps_msg[0] = '\0';
|
||||
else if (dm_snprintf(snaps_msg, sizeof(snaps_msg),
|
||||
" and %u other snapshot(s)",
|
||||
origin->origin_count - 1) < 0) {
|
||||
log_error("Failed to prepare message.");
|
||||
return ECMD_FAILED;
|
||||
}
|
||||
|
||||
if (!arg_count(cmd, yes_ARG) &&
|
||||
(yes_no_prompt("Change of snapshot %s will also change its "
|
||||
"origin %s%s. Proceed? [y/n]: ", lv->name,
|
||||
origin->name, snaps_msg) == 'n')) {
|
||||
log_error("Logical volume %s not changed.", lv->name);
|
||||
return ECMD_FAILED;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* FIXME: DEFAULT_BACKGROUND_POLLING should be "unspecified".
|
||||
* If --poll is explicitly provided use it; otherwise polling
|
||||
|
Loading…
x
Reference in New Issue
Block a user