]> sourceware.org Git - lvm2.git/commitdiff
Some extra (paranoid) checks on dev_is_{md,swap} result.
authorPetr Rockai <prokai@redhat.com>
Tue, 17 Mar 2009 14:00:58 +0000 (14:00 +0000)
committerPetr Rockai <prokai@redhat.com>
Tue, 17 Mar 2009 14:00:58 +0000 (14:00 +0000)
tools/pvcreate.c

index aa3dcff407eb3acfd02f512ad525ca510fa75d46..6ac20811fee92994223caf84d7827ddce22a37c3 100644 (file)
@@ -46,6 +46,7 @@ static int pvcreate_check(struct cmd_context *cmd, const char *name,
        struct physical_volume *pv;
        struct device *dev;
        uint64_t md_superblock, swap_signature;
+       int wipe_md, wipe_swap;
 
        /* FIXME Check partition type is LVM unless --force is given */
 
@@ -117,7 +118,7 @@ static int pvcreate_check(struct cmd_context *cmd, const char *name,
        }
 
        /* Wipe superblock? */
-       if (dev_is_md(dev, &md_superblock) &&
+       if ((wipe_md = dev_is_md(dev, &md_superblock)) == 1 &&
            ((!pp->idp && !pp->restorefile) || pp->yes ||
             (yes_no_prompt("Software RAID md superblock "
                            "detected on %s. Wipe it? [y/n] ", name) == 'y'))) {
@@ -129,7 +130,13 @@ static int pvcreate_check(struct cmd_context *cmd, const char *name,
                }
        }
 
-       if (dev_is_swap(dev, &swap_signature) &&
+       if (wipe_md == -1) {
+               log_error("Fatal error while trying to detect software "
+                         "RAID md superblock on %s", name);
+               return 0;
+       }
+
+       if ((wipe_swap = dev_is_swap(dev, &swap_signature)) == 1 &&
            ((!pp->idp && !pp->restorefile) || pp->yes ||
             (yes_no_prompt("Swap signature detected on %s. Wipe it? [y/n] ",
                            name) == 'y'))) {
@@ -140,6 +147,12 @@ static int pvcreate_check(struct cmd_context *cmd, const char *name,
                }
        }
 
+       if (wipe_swap == -1) {
+               log_error("Fatal error while trying to detect swap "
+                         "signature on %s", name);
+               return 0;
+       }
+
        if (sigint_caught())
                return 0;
 
This page took 0.043235 seconds and 5 git commands to generate.