summaryrefslogtreecommitdiffstats
path: root/tools/pvcreate.c
diff options
context:
space:
mode:
authorAlasdair Kergon <agk@redhat.com>2001-10-15 18:39:40 +0000
committerAlasdair Kergon <agk@redhat.com>2001-10-15 18:39:40 +0000
commitdf2e0dc75101a5700475f87ac22f1acf4938b1f1 (patch)
tree5f2a6cb7fd44990e71658aa01ef62f8f289f7358 /tools/pvcreate.c
parent550380f9c85371e08de61ca2d7452cc8ef060709 (diff)
downloadlvm2-df2e0dc75101a5700475f87ac22f1acf4938b1f1.tar.gz
lvm2-df2e0dc75101a5700475f87ac22f1acf4938b1f1.tar.xz
lvm2-df2e0dc75101a5700475f87ac22f1acf4938b1f1.zip
More vgcreate error trapping
Diffstat (limited to 'tools/pvcreate.c')
-rw-r--r--tools/pvcreate.c45
1 files changed, 21 insertions, 24 deletions
diff --git a/tools/pvcreate.c b/tools/pvcreate.c
index e5c29b53..58573a8f 100644
--- a/tools/pvcreate.c
+++ b/tools/pvcreate.c
@@ -13,7 +13,7 @@ const char _really_init[] =
* See if we may pvcreate on this device.
* 0 indicates we may not.
*/
-static int _check(const char *name)
+static int pvcreate_check(const char *name)
{
struct physical_volume *pv;
@@ -36,6 +36,11 @@ static int _check(const char *name)
return 0;
}
+ if (pv->status & ACTIVE) {
+ log_error("Can't create on active physical volume %s", name);
+ return 0;
+ }
+
/* we must have -ff to overwrite a non orphan */
if (arg_count(force_ARG) < 2) {
log_error("Can't initialize physical volume %s of "
@@ -50,42 +55,38 @@ static int _check(const char *name)
return 0;
}
- if (pv->status & ACTIVE) {
- log_error("Can't create on active physical volume %s", name);
- return 0;
+ if (arg_count(force_ARG)) {
+ log_print("WARNING: Forcing physical volume creation on "
+ "%s%s%s", name,
+ pv->vg_name[0] ? " of volume group " : "",
+ pv->vg_name[0] ? pv->vg_name : "");
}
return 1;
}
-static void pvcreate_single(const char *name)
+static void pvcreate_single(const char *pv_name)
{
struct physical_volume *pv;
- if (arg_count(force_ARG)) {
- log_print("WARNING: forcing physical volume creation on %s",
- name);
-
- if (pv->vg_name[0])
- log_print(" of volume group %s", pv->vg_name);
- log_print(" ");
- }
+ if (!pvcreate_check(pv_name))
+ return;
- if (!(pv = pv_create(ios, name))) {
- log_err("Failed to setup physical volume %s", name);
+ if (!(pv = pv_create(ios, pv_name))) {
+ log_err("Failed to setup physical volume %s", pv_name);
return;
}
- log_verbose("Set up physical volume for %s with %llu sectors",
- name, pv->size);
+ log_verbose("Set up physical volume for %s with %llu sectors",
+ pv_name, pv->size);
- log_verbose("Writing physical volume data to disk %s", name);
+ log_verbose("Writing physical volume data to disk %s", pv_name);
if (!(ios->pv_write(ios, pv))) {
- log_error("Failed to write physical volume %s", name);
+ log_error("Failed to write physical volume %s", pv_name);
return;
}
- log_print("Physical volume %s successfully created", name);
+ log_print("Physical volume %s successfully created", pv_name);
}
int pvcreate(int argc, char **argv)
@@ -103,10 +104,6 @@ int pvcreate(int argc, char **argv)
}
for (i = 0; i < argc; i++) {
-
- if (!_check(argv[i]))
- continue;
-
pvcreate_single(argv[i]);
pool_empty(ios->mem);
}