]> sourceware.org Git - lvm2.git/commitdiff
Restrict active lvchange -My with -f
authorAlasdair Kergon <agk@redhat.com>
Fri, 11 Jul 2003 17:10:19 +0000 (17:10 +0000)
committerAlasdair Kergon <agk@redhat.com>
Fri, 11 Jul 2003 17:10:19 +0000 (17:10 +0000)
tools/commands.h
tools/lvchange.c

index 883bd78da07bf06a9530d01720f200f4bbcff1d5..7846db96d89f8982745c0c50f44d16009566d3d7 100644 (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)
 
index 3190f5de0d7a2831e101231d77661f79aaa2e28b..ebb5927f7b3a62fc476b9dfb97f405ea5b3b690c 100644 (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;
This page took 0.049011 seconds and 5 git commands to generate.