next - vgextend: use process_each_vg
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=848dbe9644000792086b615b9fbb4d3848054437 Commit: 848dbe9644000792086b615b9fbb4d3848054437 Parent: 71ac7e22cdd6886f8121d098e3dc12b1aa3a0fc4 Author: David Teigland <[email protected]> AuthorDate: Wed Oct 22 15:32:49 2014 -0500 Committer: David Teigland <[email protected]> CommitterDate: Thu Oct 23 15:47:25 2014 -0500
vgextend: use process_each_vg
--- tools/pvcreate.c | 2 +- tools/toollib.c | 27 ++++++--- tools/toollib.h | 4 +- tools/tools.h | 2 + tools/vgcreate.c | 2 +- tools/vgextend.c | 178 ++++++++++++++++++++++++++++++------------------------ 6 files changed, 122 insertions(+), 93 deletions(-)
tools/pvcreate.c +1 -1
@@ -101,7 +101,7 @@ int pvcreate(struct cmd_context *cmd, int argc, char **argv)if (!pvcreate_restore_params_validate (cmd, argc, argv, &pp)) {return EINVALID_CMD_LINE ; } -if (!pvcreate_params_validate (cmd, argc, argv, &pp)) { +if (!pvcreate_params_validate (cmd, argc, &pp)) {return EINVALID_CMD_LINE ; }
tools/toollib.c +18 -9
@@ -861,11 +861,10 @@ void lv_spawn_background_polling(struct cmd_context *cmd,* Output arguments: * pp: structure allocated by caller, fields written / validated here */ -int pvcreate_params_validate (struct cmd_context *cmd, -int argc,char **argv, +int pvcreate_params_validate (struct cmd_context *cmd,int pv_count,struct pvcreate_params *pp) { -if (!argc) { +if (!pv_count) {log_error ("Please enter a physical volume path" );return 0 ; }
@@ -1354,6 +1353,7 @@ struct vgnameid_list {*/ static int _get_arg_vgnames (struct cmd_context *cmd,int argc,char **argv, +int only_first_name,struct dm_list *arg_vgnames,struct dm_list *arg_tags) {
@@ -1365,7 +1365,8 @@ static int _get_arg_vgnames(struct cmd_context *cmd,for (; opt < argc; opt++) { vg_name = argv[opt]; -if (*vg_name =='@' ) { + +if (!only_first_name && (*vg_name =='@' )) {if (!validate_tag (vg_name +1 )) {log_error ("Skipping invalid tag: %s" , vg_name);if (ret_max <EINVALID_CMD_LINE )
@@ -1385,13 +1386,19 @@ static int _get_arg_vgnames(struct cmd_context *cmd,log_error ("Invalid volume group name: %s" , vg_name);if (ret_max <EINVALID_CMD_LINE ) ret_max =EINVALID_CMD_LINE ; +if (only_first_name) +break ;continue ; } +if (!str_list_add (cmd->mem, arg_vgnames,dm_pool_strdup (cmd->mem, vg_name))) {log_error ("strlist allocation failed" );return ECMD_FAILED ; } + +if (only_first_name) +break ; }return ret_max;
@@ -1555,6 +1562,7 @@ int process_each_vg(struct cmd_context *cmd, int argc, char **argv,struct dm_list vgnameids_to_process;/* vgnameid_list */ int enable_all_vgs = (cmd->command->flags &ALL_VGS_IS_DEFAULT ); +int only_first_name = (flags &ONLY_FIRST_NAME );int ret;dm_list_init (&arg_tags);
@@ -1565,7 +1573,7 @@ int process_each_vg(struct cmd_context *cmd, int argc, char **argv,/* * Find any VGs or tags explicitly provided on the command line. */ -if ((ret =_get_arg_vgnames (cmd, argc, argv, &arg_vgnames, &arg_tags)) !=ECMD_PROCESSED ) { +if ((ret =_get_arg_vgnames (cmd, argc, argv, only_first_name, &arg_vgnames, &arg_tags)) !=ECMD_PROCESSED ) { stack;return ret; }
@@ -1575,10 +1583,11 @@ int process_each_vg(struct cmd_context *cmd, int argc, char **argv,* any tags were supplied and need resolving; or * no VG names were given and the command defaults to processing all VGs. */ -if (((dm_list_empty (&arg_vgnames) && enable_all_vgs) || !dm_list_empty (&arg_tags)) && - ((ret =_get_vgnameids_on_system (cmd, &vgnameids_on_system,NULL ,0 )) !=ECMD_PROCESSED )) { - stack; -return ret; +if ((dm_list_empty (&arg_vgnames) && enable_all_vgs) || !dm_list_empty (&arg_tags)) { +if ((ret =_get_vgnameids_on_system (cmd, &vgnameids_on_system,NULL ,0 )) !=ECMD_PROCESSED ) { + stack; +return ret; + } }if (dm_list_empty (&arg_vgnames) &&dm_list_empty (&vgnameids_on_system)) {
tools/toollib.h +2 -2
@@ -103,8 +103,8 @@ int vg_refresh_visible(struct cmd_context *cmd, struct volume_group *vg);void lv_spawn_background_polling (struct cmd_context *cmd,struct logical_volume *lv);int pvcreate_params_validate (struct cmd_context *cmd, -int argc,char **argv, -struct pvcreate_params *pp); +int pv_count, +struct pvcreate_params *pp);int get_activation_monitoring_mode (struct cmd_context *cmd,int *monitoring_mode);
tools/tools.h +2 -0
@@ -106,6 +106,8 @@ struct arg_value_group_list {#define ALL_VGS_IS_DEFAULT 0x00000004/* Process all devices with --all if none are specified on the command line. */ #define ENABLE_ALL_DEVS 0x00000008 +/* Use only the first free arg as the vg name. */ +#define ONLY_FIRST_NAME 0x00000010/* a register of the lvm commands */ struct command {
tools/vgcreate.c +1 -1
@@ -37,7 +37,7 @@ int vgcreate(struct cmd_context *cmd, int argc, char **argv) argv++;pvcreate_params_set_defaults (&pp); -if (!pvcreate_params_validate (cmd, argc, argv, &pp)) { +if (!pvcreate_params_validate (cmd, argc, &pp)) {return EINVALID_CMD_LINE ; }
tools/vgextend.c +98 -80
208 lines not on this page · raw message