1
0
mirror of git://sourceware.org/git/lvm2.git synced 2024-12-23 21:35:29 +03:00

Restrict active lvchange -My with -f

This commit is contained in:
Alasdair Kergon 2003-07-11 17:10:19 +00:00
parent 72542059dd
commit 8c9cd10b8b
2 changed files with 16 additions and 3 deletions

View File

@ -54,6 +54,7 @@ xx(lvchange,
"\t[-a|--available y|n]\n"
"\t[-C|--contiguous y|n]\n"
"\t[-d|--debug]\n"
"\t[-f|--force]\n"
"\t[-h|--help]\n"
"\t[--ignorelockingfailure]\n"
"\t[-M|--persistent y|n] [--major major] [--minor minor]\n"
@ -65,7 +66,7 @@ xx(lvchange,
"\t[--version]" "\n"
"\tLogicalVolume[Path] [LogicalVolume[Path]...]\n",
autobackup_ARG, available_ARG, contiguous_ARG,
autobackup_ARG, available_ARG, contiguous_ARG, force_ARG,
ignorelockingfailure_ARG, major_ARG, minor_ARG, partial_ARG, permission_ARG,
persistent_ARG, readahead_ARG, test_ARG)

View File

@ -227,6 +227,7 @@ static int lvchange_readahead(struct cmd_context *cmd,
static int lvchange_persistent(struct cmd_context *cmd,
struct logical_volume *lv)
{
struct lvinfo info;
if (!strcmp(arg_str_value(cmd, persistent_ARG, "n"), "n")) {
if (!(lv->status & FIXED_MINOR)) {
@ -248,8 +249,19 @@ static int lvchange_persistent(struct cmd_context *cmd,
log_error("Major number must be specified with -My");
return 0;
}
log_verbose("Ensuring %s is inactive. Reactivate with -ay.",
lv->name);
if (lv_info(lv, &info) && info.exists &&
!arg_count(cmd, force_ARG)) {
if (yes_no_prompt("Logical volume %s will be "
"deactivated first. "
"Continue? [y/n]: ",
lv->name) == 'n') {
log_print("%s device number not changed.",
lv->name);
return 0;
}
}
log_print("Ensuring %s is inactive. "
"(Reactivate using lvchange -ay.)", lv->name);
if (!lock_vol(cmd, lv->lvid.s, LCK_LV_DEACTIVATE)) {
log_error("%s: deactivation failed", lv->name);
return 0;