1
0
mirror of git://sourceware.org/git/lvm2.git synced 2024-12-22 17:35:59 +03:00

Refactor vgcreate/vgextend validation of vgname/pvname(s).

Decrement argc and increment argv in a consistent way to allow for later
code-sharing.  Should be no functional change.
This commit is contained in:
Dave Wysochanski 2009-10-05 20:03:37 +00:00
parent 5a4813d336
commit 877de45d6e
2 changed files with 13 additions and 8 deletions

View File

@ -22,6 +22,7 @@ int vgcreate(struct cmd_context *cmd, int argc, char **argv)
struct volume_group *vg;
const char *tag;
const char *clustered_message = "";
char *vg_name;
if (!argc) {
log_error("Please provide volume group name and "
@ -29,7 +30,11 @@ int vgcreate(struct cmd_context *cmd, int argc, char **argv)
return EINVALID_CMD_LINE;
}
if (argc == 1) {
vg_name = argv[0];
argc--;
argv++;
if (argc == 0) {
log_error("Please enter physical volume name(s)");
return EINVALID_CMD_LINE;
}
@ -40,7 +45,7 @@ int vgcreate(struct cmd_context *cmd, int argc, char **argv)
vp_def.max_lv = DEFAULT_MAX_LV;
vp_def.alloc = DEFAULT_ALLOC_POLICY;
vp_def.clustered = DEFAULT_CLUSTERED;
if (fill_vg_create_params(cmd, argv[0], &vp_new, &vp_def))
if (fill_vg_create_params(cmd, vg_name, &vp_new, &vp_def))
return EINVALID_CMD_LINE;
if (validate_vg_create_params(cmd, &vp_new))
@ -63,7 +68,7 @@ int vgcreate(struct cmd_context *cmd, int argc, char **argv)
}
/* attach the pv's */
if (!vg_extend(vg, argc - 1, argv + 1, NULL))
if (!vg_extend(vg, argc, argv, NULL))
goto_bad;
if (vp_new.max_lv != vg->max_lv)

View File

@ -27,15 +27,15 @@ int vgextend(struct cmd_context *cmd, int argc, char **argv)
return EINVALID_CMD_LINE;
}
if (argc == 1) {
log_error("Please enter physical volume(s)");
return EINVALID_CMD_LINE;
}
vg_name = skip_dev_dir(cmd, argv[0], NULL);
argc--;
argv++;
if (argc == 0) {
log_error("Please enter physical volume(s)");
return EINVALID_CMD_LINE;
}
log_verbose("Checking for volume group \"%s\"", vg_name);
vg = vg_read_for_update(cmd, vg_name, NULL, 0);
if (vg_read_error(vg)) {