summaryrefslogtreecommitdiffstats
path: root/tools/pvcreate.c
diff options
context:
space:
mode:
authorPetr Rockai <prockai@redhat.com>2009-03-17 14:00:58 +0000
committerPetr Rockai <prockai@redhat.com>2009-03-17 14:00:58 +0000
commita9d72f0e9d3ef4a5abaf4cc27f29589751209f90 (patch)
tree3b166a16cbf2daf4cee0793b6875f9042d05cb1b /tools/pvcreate.c
parent3402ccd488f9617a3e8ce77258e8596cb59531b3 (diff)
downloadlvm2-a9d72f0e9d3ef4a5abaf4cc27f29589751209f90.tar.gz
lvm2-a9d72f0e9d3ef4a5abaf4cc27f29589751209f90.tar.xz
lvm2-a9d72f0e9d3ef4a5abaf4cc27f29589751209f90.zip
Some extra (paranoid) checks on dev_is_{md,swap} result.
Diffstat (limited to 'tools/pvcreate.c')
-rw-r--r--tools/pvcreate.c17
1 files changed, 15 insertions, 2 deletions
diff --git a/tools/pvcreate.c b/tools/pvcreate.c
index aa3dcff4..6ac20811 100644
--- a/tools/pvcreate.c
+++ b/tools/pvcreate.c
@@ -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;