1
0
mirror of git://sourceware.org/git/lvm2.git synced 2025-03-28 02:50:41 +03:00

Refactor pvcreate - simplify return codes.

This commit is contained in:
Dave Wysochanski 2008-07-25 14:59:51 +00:00
parent 0e74f8fc65
commit 65a431fe1f
2 changed files with 20 additions and 8 deletions

View File

@ -42,6 +42,18 @@ test_expect_success \
vgremove -f $vg1 &&
pvremove -f $d1'
test_expect_success \
"pvcreate (lvm$mdatype) fails when PV1 does and PV2 does not belong to VG" \
'pvcreate -M$mdatype $d1 &&
pvcreate -M$mdatype $d2 &&
vgcreate -M$mdatype $vg1 $d1 &&
echo pvcreate a second time on $d2 and $d1 &&
pvcreate -M$mdatype $d2 $d1;
status=$?; echo status=$status; test $status != 0 &&
vgremove -f $vg1 &&
pvremove -f $d2 &&
pvremove -f $d1'
done
test_expect_success \

View File

@ -153,13 +153,13 @@ static int pvcreate_single(struct cmd_context *cmd, const char *pv_name,
(dev != dev_cache_get(pv_name, cmd->filter))) {
log_error("uuid %s already in use on \"%s\"",
pp->idp->uuid, dev_name(dev));
return ECMD_FAILED;
return 0;
}
}
if (!lock_vol(cmd, VG_ORPHANS, LCK_VG_WRITE)) {
log_error("Can't get lock for orphan PVs");
return ECMD_FAILED;
return 0;
}
if (!pvcreate_check(cmd, pv_name, pp))
@ -218,11 +218,11 @@ static int pvcreate_single(struct cmd_context *cmd, const char *pv_name,
log_print("Physical volume \"%s\" successfully created", pv_name);
unlock_vg(cmd, VG_ORPHANS);
return ECMD_PROCESSED;
return 1;
error:
unlock_vg(cmd, VG_ORPHANS);
return ECMD_FAILED;
return 0;
}
/*
@ -352,7 +352,7 @@ static int pvcreate_validate_params(struct cmd_context *cmd,
int pvcreate(struct cmd_context *cmd, int argc, char **argv)
{
int i, r;
int i;
int ret = ECMD_PROCESSED;
struct pvcreate_params pp;
@ -361,9 +361,9 @@ int pvcreate(struct cmd_context *cmd, int argc, char **argv)
}
for (i = 0; i < argc; i++) {
r = pvcreate_single(cmd, argv[i], &pp);
if (r > ret)
ret = r;
if (!pvcreate_single(cmd, argv[i], &pp))
ret = ECMD_FAILED;
if (sigint_caught())
return ret;
}