mirror of
git://sourceware.org/git/lvm2.git
synced 2025-02-16 13:57:49 +03:00
tools: Use arg_is_set instead of arg_count.
This commit is contained in:
parent
6c269e639a
commit
7e671e5dd0
@ -20,9 +20,9 @@ static int _get_vsn(struct cmd_context *cmd, uint16_t *version_int)
|
||||
const char *vsn;
|
||||
unsigned int major, minor, patchlevel;
|
||||
|
||||
if (arg_count(cmd, atversion_ARG))
|
||||
if (arg_is_set(cmd, atversion_ARG))
|
||||
vsn = arg_str_value(cmd, atversion_ARG, NULL);
|
||||
else if (arg_count(cmd, sinceversion_ARG))
|
||||
else if (arg_is_set(cmd, sinceversion_ARG))
|
||||
vsn = arg_str_value(cmd, sinceversion_ARG, NULL);
|
||||
else
|
||||
vsn = LVM_VERSION;
|
||||
@ -98,7 +98,7 @@ static int _config_validate(struct cmd_context *cmd, struct dm_config_tree *cft)
|
||||
int dumpconfig(struct cmd_context *cmd, int argc, char **argv)
|
||||
{
|
||||
const char *file = arg_str_value(cmd, file_ARG, NULL);
|
||||
const char *type = arg_str_value(cmd, configtype_ARG, arg_count(cmd, list_ARG) ? "list" : "current");
|
||||
const char *type = arg_str_value(cmd, configtype_ARG, arg_is_set(cmd, list_ARG) ? "list" : "current");
|
||||
struct config_def_tree_spec tree_spec = {0};
|
||||
struct dm_config_tree *cft = NULL;
|
||||
struct cft_check_handle *cft_check_handle = NULL;
|
||||
@ -107,43 +107,43 @@ int dumpconfig(struct cmd_context *cmd, int argc, char **argv)
|
||||
|
||||
tree_spec.cmd = cmd;
|
||||
|
||||
if (arg_count(cmd, configtype_ARG) && arg_count(cmd, validate_ARG)) {
|
||||
if (arg_is_set(cmd, configtype_ARG) && arg_is_set(cmd, validate_ARG)) {
|
||||
log_error("Only one of --type and --validate permitted.");
|
||||
return EINVALID_CMD_LINE;
|
||||
}
|
||||
|
||||
if (arg_count(cmd, configtype_ARG) && arg_count(cmd, list_ARG)) {
|
||||
if (arg_is_set(cmd, configtype_ARG) && arg_is_set(cmd, list_ARG)) {
|
||||
log_error("Only one of --type and --list permitted.");
|
||||
return EINVALID_CMD_LINE;
|
||||
}
|
||||
|
||||
if (arg_count(cmd, atversion_ARG)) {
|
||||
if (arg_count(cmd, sinceversion_ARG)) {
|
||||
if (arg_is_set(cmd, atversion_ARG)) {
|
||||
if (arg_is_set(cmd, sinceversion_ARG)) {
|
||||
log_error("Only one of --atversion and --sinceversion permitted.");
|
||||
return EINVALID_CMD_LINE;
|
||||
}
|
||||
|
||||
if (!arg_count(cmd, configtype_ARG) && !arg_count(cmd, list_ARG)) {
|
||||
if (!arg_is_set(cmd, configtype_ARG) && !arg_is_set(cmd, list_ARG)) {
|
||||
log_error("--atversion requires --type or --list");
|
||||
return EINVALID_CMD_LINE;
|
||||
}
|
||||
} else if (arg_count(cmd, sinceversion_ARG)) {
|
||||
if (!arg_count(cmd, configtype_ARG) || strcmp(type, "new")) {
|
||||
} else if (arg_is_set(cmd, sinceversion_ARG)) {
|
||||
if (!arg_is_set(cmd, configtype_ARG) || strcmp(type, "new")) {
|
||||
log_error("--sinceversion requires --type new");
|
||||
return EINVALID_CMD_LINE;
|
||||
}
|
||||
}
|
||||
|
||||
if (arg_count(cmd, ignoreadvanced_ARG))
|
||||
if (arg_is_set(cmd, ignoreadvanced_ARG))
|
||||
tree_spec.ignoreadvanced = 1;
|
||||
|
||||
if (arg_count(cmd, ignoreunsupported_ARG)) {
|
||||
if (arg_count(cmd, showunsupported_ARG)) {
|
||||
if (arg_is_set(cmd, ignoreunsupported_ARG)) {
|
||||
if (arg_is_set(cmd, showunsupported_ARG)) {
|
||||
log_error("Only one of --ignoreunsupported and --showunsupported permitted.");
|
||||
return EINVALID_CMD_LINE;
|
||||
}
|
||||
tree_spec.ignoreunsupported = 1;
|
||||
} else if (arg_count(cmd, showunsupported_ARG)) {
|
||||
} else if (arg_is_set(cmd, showunsupported_ARG)) {
|
||||
tree_spec.ignoreunsupported = 0;
|
||||
} else if (strcmp(type, "current") && strcmp(type, "diff")) {
|
||||
/*
|
||||
@ -165,28 +165,28 @@ int dumpconfig(struct cmd_context *cmd, int argc, char **argv)
|
||||
* is lower than the version in which the
|
||||
* setting was deprecated.
|
||||
*/
|
||||
if (!arg_count(cmd, showdeprecated_ARG))
|
||||
if (!arg_is_set(cmd, showdeprecated_ARG))
|
||||
tree_spec.ignoredeprecated = 1;
|
||||
}
|
||||
|
||||
if (arg_count(cmd, ignorelocal_ARG))
|
||||
if (arg_is_set(cmd, ignorelocal_ARG))
|
||||
tree_spec.ignorelocal = 1;
|
||||
|
||||
if (!strcmp(type, "current") || !strcmp(type, "full")) {
|
||||
if (arg_count(cmd, atversion_ARG)) {
|
||||
if (arg_is_set(cmd, atversion_ARG)) {
|
||||
log_error("--atversion has no effect with --type %s", type);
|
||||
return EINVALID_CMD_LINE;
|
||||
}
|
||||
|
||||
if ((arg_count(cmd, ignoreunsupported_ARG) ||
|
||||
arg_count(cmd, ignoreadvanced_ARG)) &&
|
||||
if ((arg_is_set(cmd, ignoreunsupported_ARG) ||
|
||||
arg_is_set(cmd, ignoreadvanced_ARG)) &&
|
||||
!strcmp(type, "current")) {
|
||||
/* FIXME: allow these even for --type current */
|
||||
log_error("--ignoreadvanced and --ignoreunsupported has "
|
||||
"no effect with --type current");
|
||||
return EINVALID_CMD_LINE;
|
||||
}
|
||||
} else if (arg_count(cmd, mergedconfig_ARG)) {
|
||||
} else if (arg_is_set(cmd, mergedconfig_ARG)) {
|
||||
log_error("--mergedconfig has no effect without --type current or --type full");
|
||||
return EINVALID_CMD_LINE;
|
||||
}
|
||||
@ -199,7 +199,7 @@ int dumpconfig(struct cmd_context *cmd, int argc, char **argv)
|
||||
* but it is used just for dumping the profile content and not for
|
||||
* application.
|
||||
*/
|
||||
if (arg_count(cmd, profile_ARG) &&
|
||||
if (arg_is_set(cmd, profile_ARG) &&
|
||||
(!(profile = add_profile(cmd, arg_str_value(cmd, profile_ARG, NULL), CONFIG_PROFILE_COMMAND)) ||
|
||||
!override_config_tree_from_profile(cmd, profile))) {
|
||||
log_error("Failed to load profile %s.", arg_str_value(cmd, profile_ARG, NULL));
|
||||
@ -210,7 +210,7 @@ int dumpconfig(struct cmd_context *cmd, int argc, char **argv)
|
||||
* Set the 'cft' to work with based on whether we need the plain
|
||||
* config tree or merged config tree cascade if --mergedconfig is used.
|
||||
*/
|
||||
if ((arg_count(cmd, mergedconfig_ARG) || !strcmp(type, "full") || !strcmp(type, "diff")) && cmd->cft->cascade) {
|
||||
if ((arg_is_set(cmd, mergedconfig_ARG) || !strcmp(type, "full") || !strcmp(type, "diff")) && cmd->cft->cascade) {
|
||||
if (!_merge_config_cascade(cmd, cmd->cft, &cft)) {
|
||||
log_error("Failed to merge configuration.");
|
||||
r = ECMD_FAILED;
|
||||
@ -220,7 +220,7 @@ int dumpconfig(struct cmd_context *cmd, int argc, char **argv)
|
||||
cft = cmd->cft;
|
||||
tree_spec.current_cft = cft;
|
||||
|
||||
if (arg_count(cmd, validate_ARG)) {
|
||||
if (arg_is_set(cmd, validate_ARG)) {
|
||||
if (_config_validate(cmd, cft)) {
|
||||
log_print("LVM configuration valid.");
|
||||
goto out;
|
||||
@ -231,9 +231,9 @@ int dumpconfig(struct cmd_context *cmd, int argc, char **argv)
|
||||
}
|
||||
}
|
||||
|
||||
if (!strcmp(type, "list") || arg_count(cmd, list_ARG)) {
|
||||
if (!strcmp(type, "list") || arg_is_set(cmd, list_ARG)) {
|
||||
tree_spec.type = CFG_DEF_TREE_LIST;
|
||||
if (arg_count(cmd, withcomments_ARG)) {
|
||||
if (arg_is_set(cmd, withcomments_ARG)) {
|
||||
log_error("--withcomments has no effect with --type list");
|
||||
return EINVALID_CMD_LINE;
|
||||
}
|
||||
@ -270,7 +270,7 @@ int dumpconfig(struct cmd_context *cmd, int argc, char **argv)
|
||||
}
|
||||
}
|
||||
else if (!strcmp(type, "new")) {
|
||||
tree_spec.type = arg_count(cmd, sinceversion_ARG) ? CFG_DEF_TREE_NEW_SINCE
|
||||
tree_spec.type = arg_is_set(cmd, sinceversion_ARG) ? CFG_DEF_TREE_NEW_SINCE
|
||||
: CFG_DEF_TREE_NEW;
|
||||
/* new type does not require check status */
|
||||
}
|
||||
@ -294,17 +294,17 @@ int dumpconfig(struct cmd_context *cmd, int argc, char **argv)
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (arg_count(cmd, withsummary_ARG) || arg_count(cmd, list_ARG))
|
||||
if (arg_is_set(cmd, withsummary_ARG) || arg_is_set(cmd, list_ARG))
|
||||
tree_spec.withsummary = 1;
|
||||
if (arg_count(cmd, withcomments_ARG))
|
||||
if (arg_is_set(cmd, withcomments_ARG))
|
||||
tree_spec.withcomments = 1;
|
||||
if (arg_count(cmd, unconfigured_ARG))
|
||||
if (arg_is_set(cmd, unconfigured_ARG))
|
||||
tree_spec.unconfigured = 1;
|
||||
|
||||
if (arg_count(cmd, withversions_ARG))
|
||||
if (arg_is_set(cmd, withversions_ARG))
|
||||
tree_spec.withversions = 1;
|
||||
|
||||
if (arg_count(cmd, withspaces_ARG))
|
||||
if (arg_is_set(cmd, withspaces_ARG))
|
||||
tree_spec.withspaces = 1;
|
||||
|
||||
if (cft_check_handle)
|
||||
|
116
tools/lvchange.c
116
tools/lvchange.c
@ -108,7 +108,7 @@ static int _lvchange_pool_update(struct cmd_context *cmd,
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (arg_count(cmd, discards_ARG)) {
|
||||
if (arg_is_set(cmd, discards_ARG)) {
|
||||
discards = (thin_discards_t) arg_uint_value(cmd, discards_ARG, THIN_DISCARDS_IGNORE);
|
||||
if (discards != first_seg(lv)->discards) {
|
||||
if (((discards == THIN_DISCARDS_IGNORE) ||
|
||||
@ -124,7 +124,7 @@ static int _lvchange_pool_update(struct cmd_context *cmd,
|
||||
lv->name, get_pool_discards_name(discards));
|
||||
}
|
||||
|
||||
if (arg_count(cmd, zero_ARG)) {
|
||||
if (arg_is_set(cmd, zero_ARG)) {
|
||||
val = arg_uint_value(cmd, zero_ARG, 1);
|
||||
if (val != first_seg(lv)->zero_new_blocks) {
|
||||
first_seg(lv)->zero_new_blocks = val;
|
||||
@ -200,7 +200,7 @@ static int _lvchange_activate(struct cmd_context *cmd, struct logical_volume *lv
|
||||
return ECMD_FAILED;
|
||||
}
|
||||
|
||||
if (lv_activation_skip(lv, activate, arg_count(cmd, ignoreactivationskip_ARG)))
|
||||
if (lv_activation_skip(lv, activate, arg_is_set(cmd, ignoreactivationskip_ARG)))
|
||||
return 1;
|
||||
|
||||
if (lv_is_cow(lv) && !lv_is_virtual_origin(origin_from_cow(lv)))
|
||||
@ -350,7 +350,7 @@ static int _lvchange_resync(struct cmd_context *cmd, struct logical_volume *lv)
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!arg_count(cmd, yes_ARG) &&
|
||||
if (!arg_is_set(cmd, yes_ARG) &&
|
||||
yes_no_prompt("Do you really want to deactivate "
|
||||
"logical volume %s to resync it? [y/n]: ",
|
||||
lv->name) == 'n') {
|
||||
@ -625,8 +625,8 @@ static int _lvchange_persistent(struct cmd_context *cmd,
|
||||
display_lvname(lv));
|
||||
} else {
|
||||
if (lv_is_active(lv)) {
|
||||
if (!arg_count(cmd, force_ARG) &&
|
||||
!arg_count(cmd, yes_ARG) &&
|
||||
if (!arg_is_set(cmd, force_ARG) &&
|
||||
!arg_is_set(cmd, yes_ARG) &&
|
||||
yes_no_prompt("Logical volume %s will be "
|
||||
"deactivated temporarily. "
|
||||
"Continue? [y/n]: ", lv->name) == 'n') {
|
||||
@ -760,11 +760,11 @@ static int _lvchange_writemostly(struct logical_volume *lv)
|
||||
|
||||
if (!seg_is_raid1(raid_seg)) {
|
||||
log_error("--write%s can only be used with 'raid1' segment type",
|
||||
arg_count(cmd, writemostly_ARG) ? "mostly" : "behind");
|
||||
arg_is_set(cmd, writemostly_ARG) ? "mostly" : "behind");
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (arg_count(cmd, writebehind_ARG))
|
||||
if (arg_is_set(cmd, writebehind_ARG))
|
||||
raid_seg->writebehind = arg_uint_value(cmd, writebehind_ARG, 0);
|
||||
|
||||
if ((pv_count = arg_count(cmd, writemostly_ARG))) {
|
||||
@ -858,10 +858,10 @@ static int _lvchange_recovery_rate(struct logical_volume *lv)
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (arg_count(cmd, minrecoveryrate_ARG))
|
||||
if (arg_is_set(cmd, minrecoveryrate_ARG))
|
||||
raid_seg->min_recovery_rate =
|
||||
arg_uint_value(cmd, minrecoveryrate_ARG, 0) / 2;
|
||||
if (arg_count(cmd, maxrecoveryrate_ARG))
|
||||
if (arg_is_set(cmd, maxrecoveryrate_ARG))
|
||||
raid_seg->max_recovery_rate =
|
||||
arg_uint_value(cmd, maxrecoveryrate_ARG, 0) / 2;
|
||||
|
||||
@ -885,11 +885,11 @@ static int _lvchange_profile(struct logical_volume *lv)
|
||||
|
||||
old_profile_name = lv->profile ? lv->profile->name : "(inherited)";
|
||||
|
||||
if (arg_count(lv->vg->cmd, detachprofile_ARG)) {
|
||||
if (arg_is_set(lv->vg->cmd, detachprofile_ARG)) {
|
||||
new_profile_name = "(inherited)";
|
||||
lv->profile = NULL;
|
||||
} else {
|
||||
if (arg_count(lv->vg->cmd, metadataprofile_ARG))
|
||||
if (arg_is_set(lv->vg->cmd, metadataprofile_ARG))
|
||||
new_profile_name = arg_str_value(lv->vg->cmd, metadataprofile_ARG, NULL);
|
||||
else
|
||||
new_profile_name = arg_str_value(lv->vg->cmd, profile_ARG, NULL);
|
||||
@ -971,7 +971,7 @@ static int _lvchange_single(struct cmd_context *cmd, struct logical_volume *lv,
|
||||
|
||||
if (lv_is_pvmove(lv)) {
|
||||
log_error("Unable to change pvmove LV %s", lv->name);
|
||||
if (arg_count(cmd, activate_ARG))
|
||||
if (arg_is_set(cmd, activate_ARG))
|
||||
log_error("Use 'pvmove --abort' to abandon a pvmove");
|
||||
return ECMD_FAILED;
|
||||
}
|
||||
@ -988,15 +988,15 @@ static int _lvchange_single(struct cmd_context *cmd, struct logical_volume *lv,
|
||||
}
|
||||
|
||||
/* If LV is sparse, activate origin instead */
|
||||
if (arg_count(cmd, activate_ARG) && lv_is_cow(lv) &&
|
||||
if (arg_is_set(cmd, activate_ARG) && lv_is_cow(lv) &&
|
||||
lv_is_virtual_origin(origin = origin_from_cow(lv)))
|
||||
lv = origin;
|
||||
|
||||
if ((lv_is_thin_pool_data(lv) || lv_is_thin_pool_metadata(lv) ||
|
||||
lv_is_cache_pool_data(lv) || lv_is_cache_pool_metadata(lv)) &&
|
||||
!arg_count(cmd, activate_ARG) &&
|
||||
!arg_count(cmd, permission_ARG) &&
|
||||
!arg_count(cmd, setactivationskip_ARG))
|
||||
!arg_is_set(cmd, activate_ARG) &&
|
||||
!arg_is_set(cmd, permission_ARG) &&
|
||||
!arg_is_set(cmd, setactivationskip_ARG))
|
||||
/* Rest can be changed for stacked thin pool meta/data volumes */
|
||||
;
|
||||
else if (!lv_is_visible(lv) && !lv_is_virtual_origin(lv)) {
|
||||
@ -1005,7 +1005,7 @@ static int _lvchange_single(struct cmd_context *cmd, struct logical_volume *lv,
|
||||
return ECMD_FAILED;
|
||||
}
|
||||
|
||||
if (lv_is_cow(lv) && arg_count(cmd, activate_ARG)) {
|
||||
if (lv_is_cow(lv) && arg_is_set(cmd, activate_ARG)) {
|
||||
origin = origin_from_cow(lv);
|
||||
if (origin->origin_count < 2)
|
||||
snaps_msg[0] = '\0';
|
||||
@ -1016,7 +1016,7 @@ static int _lvchange_single(struct cmd_context *cmd, struct logical_volume *lv,
|
||||
return ECMD_FAILED;
|
||||
}
|
||||
|
||||
if (!arg_count(cmd, yes_ARG) &&
|
||||
if (!arg_is_set(cmd, yes_ARG) &&
|
||||
(yes_no_prompt("Change of snapshot %s will also change its "
|
||||
"origin %s%s. Proceed? [y/n]: ",
|
||||
display_lvname(lv), display_lvname(origin),
|
||||
@ -1031,12 +1031,12 @@ static int _lvchange_single(struct cmd_context *cmd, struct logical_volume *lv,
|
||||
return ECMD_FAILED;
|
||||
}
|
||||
|
||||
if (arg_count(cmd, persistent_ARG) && lv_is_pool(lv)) {
|
||||
if (arg_is_set(cmd, persistent_ARG) && lv_is_pool(lv)) {
|
||||
log_error("Persistent major and minor numbers are not supported with pools.");
|
||||
return ECMD_FAILED;
|
||||
}
|
||||
|
||||
if (!arg_count(cmd, activate_ARG) && !arg_count(cmd, refresh_ARG)) {
|
||||
if (!arg_is_set(cmd, activate_ARG) && !arg_is_set(cmd, refresh_ARG)) {
|
||||
/*
|
||||
* If a persistent lv lock already exists from activation
|
||||
* (with the needed mode or higher), this will be a no-op.
|
||||
@ -1061,12 +1061,12 @@ static int _lvchange_single(struct cmd_context *cmd, struct logical_volume *lv,
|
||||
*
|
||||
* Do not initiate any polling if --sysinit option is used.
|
||||
*/
|
||||
init_background_polling(arg_count(cmd, sysinit_ARG) ? 0 :
|
||||
init_background_polling(arg_is_set(cmd, sysinit_ARG) ? 0 :
|
||||
arg_int_value(cmd, poll_ARG,
|
||||
DEFAULT_BACKGROUND_POLLING));
|
||||
|
||||
/* access permission change */
|
||||
if (arg_count(cmd, permission_ARG)) {
|
||||
if (arg_is_set(cmd, permission_ARG)) {
|
||||
if (!archive(lv->vg))
|
||||
return_ECMD_FAILED;
|
||||
doit += _lvchange_permission(cmd, lv);
|
||||
@ -1074,7 +1074,7 @@ static int _lvchange_single(struct cmd_context *cmd, struct logical_volume *lv,
|
||||
}
|
||||
|
||||
/* allocation policy change */
|
||||
if (arg_count(cmd, contiguous_ARG) || arg_count(cmd, alloc_ARG)) {
|
||||
if (arg_is_set(cmd, contiguous_ARG) || arg_is_set(cmd, alloc_ARG)) {
|
||||
if (!archive(lv->vg))
|
||||
return_ECMD_FAILED;
|
||||
doit += _lvchange_alloc(cmd, lv);
|
||||
@ -1082,7 +1082,7 @@ static int _lvchange_single(struct cmd_context *cmd, struct logical_volume *lv,
|
||||
}
|
||||
|
||||
/* error when full change */
|
||||
if (arg_count(cmd, errorwhenfull_ARG)) {
|
||||
if (arg_is_set(cmd, errorwhenfull_ARG)) {
|
||||
if (!archive(lv->vg))
|
||||
return_ECMD_FAILED;
|
||||
doit += _lvchange_errorwhenfull(cmd, lv);
|
||||
@ -1090,7 +1090,7 @@ static int _lvchange_single(struct cmd_context *cmd, struct logical_volume *lv,
|
||||
}
|
||||
|
||||
/* read ahead sector change */
|
||||
if (arg_count(cmd, readahead_ARG)) {
|
||||
if (arg_is_set(cmd, readahead_ARG)) {
|
||||
if (!archive(lv->vg))
|
||||
return_ECMD_FAILED;
|
||||
doit += _lvchange_readahead(cmd, lv);
|
||||
@ -1098,15 +1098,15 @@ static int _lvchange_single(struct cmd_context *cmd, struct logical_volume *lv,
|
||||
}
|
||||
|
||||
/* persistent device number change */
|
||||
if (arg_count(cmd, persistent_ARG)) {
|
||||
if (arg_is_set(cmd, persistent_ARG)) {
|
||||
if (!archive(lv->vg))
|
||||
return_ECMD_FAILED;
|
||||
doit += _lvchange_persistent(cmd, lv);
|
||||
docmds++;
|
||||
}
|
||||
|
||||
if (arg_count(cmd, discards_ARG) ||
|
||||
arg_count(cmd, zero_ARG)) {
|
||||
if (arg_is_set(cmd, discards_ARG) ||
|
||||
arg_is_set(cmd, zero_ARG)) {
|
||||
if (!archive(lv->vg))
|
||||
return_ECMD_FAILED;
|
||||
doit += _lvchange_pool_update(cmd, lv);
|
||||
@ -1114,7 +1114,7 @@ static int _lvchange_single(struct cmd_context *cmd, struct logical_volume *lv,
|
||||
}
|
||||
|
||||
/* add tag */
|
||||
if (arg_count(cmd, addtag_ARG)) {
|
||||
if (arg_is_set(cmd, addtag_ARG)) {
|
||||
if (!archive(lv->vg))
|
||||
return_ECMD_FAILED;
|
||||
doit += _lvchange_tag(cmd, lv, addtag_ARG);
|
||||
@ -1122,7 +1122,7 @@ static int _lvchange_single(struct cmd_context *cmd, struct logical_volume *lv,
|
||||
}
|
||||
|
||||
/* del tag */
|
||||
if (arg_count(cmd, deltag_ARG)) {
|
||||
if (arg_is_set(cmd, deltag_ARG)) {
|
||||
if (!archive(lv->vg))
|
||||
return_ECMD_FAILED;
|
||||
doit += _lvchange_tag(cmd, lv, deltag_ARG);
|
||||
@ -1130,7 +1130,7 @@ static int _lvchange_single(struct cmd_context *cmd, struct logical_volume *lv,
|
||||
}
|
||||
|
||||
/* change writemostly/writebehind */
|
||||
if (arg_count(cmd, writemostly_ARG) || arg_count(cmd, writebehind_ARG)) {
|
||||
if (arg_is_set(cmd, writemostly_ARG) || arg_is_set(cmd, writebehind_ARG)) {
|
||||
if (!archive(lv->vg))
|
||||
return_ECMD_FAILED;
|
||||
doit += _lvchange_writemostly(lv);
|
||||
@ -1138,8 +1138,8 @@ static int _lvchange_single(struct cmd_context *cmd, struct logical_volume *lv,
|
||||
}
|
||||
|
||||
/* change [min|max]_recovery_rate */
|
||||
if (arg_count(cmd, minrecoveryrate_ARG) ||
|
||||
arg_count(cmd, maxrecoveryrate_ARG)) {
|
||||
if (arg_is_set(cmd, minrecoveryrate_ARG) ||
|
||||
arg_is_set(cmd, maxrecoveryrate_ARG)) {
|
||||
if (!archive(lv->vg))
|
||||
return_ECMD_FAILED;
|
||||
doit += _lvchange_recovery_rate(lv);
|
||||
@ -1147,15 +1147,15 @@ static int _lvchange_single(struct cmd_context *cmd, struct logical_volume *lv,
|
||||
}
|
||||
|
||||
/* change configuration profile */
|
||||
if (arg_count(cmd, profile_ARG) || arg_count(cmd, metadataprofile_ARG) ||
|
||||
arg_count(cmd, detachprofile_ARG)) {
|
||||
if (arg_is_set(cmd, profile_ARG) || arg_is_set(cmd, metadataprofile_ARG) ||
|
||||
arg_is_set(cmd, detachprofile_ARG)) {
|
||||
if (!archive(lv->vg))
|
||||
return_ECMD_FAILED;
|
||||
doit += _lvchange_profile(lv);
|
||||
docmds++;
|
||||
}
|
||||
|
||||
if (arg_count(cmd, setactivationskip_ARG)) {
|
||||
if (arg_is_set(cmd, setactivationskip_ARG)) {
|
||||
if (!archive(lv->vg))
|
||||
return_ECMD_FAILED;
|
||||
doit += _lvchange_activation_skip(lv);
|
||||
@ -1163,7 +1163,7 @@ static int _lvchange_single(struct cmd_context *cmd, struct logical_volume *lv,
|
||||
}
|
||||
|
||||
if (arg_is_set(cmd, cachemode_ARG) ||
|
||||
arg_count(cmd, cachepolicy_ARG) || arg_count(cmd, cachesettings_ARG)) {
|
||||
arg_is_set(cmd, cachepolicy_ARG) || arg_is_set(cmd, cachesettings_ARG)) {
|
||||
if (!archive(lv->vg))
|
||||
return_ECMD_FAILED;
|
||||
doit += _lvchange_cache(cmd, lv);
|
||||
@ -1173,27 +1173,27 @@ static int _lvchange_single(struct cmd_context *cmd, struct logical_volume *lv,
|
||||
if (doit)
|
||||
log_print_unless_silent("Logical volume %s changed.", display_lvname(lv));
|
||||
|
||||
if (arg_count(cmd, resync_ARG) &&
|
||||
if (arg_is_set(cmd, resync_ARG) &&
|
||||
!_lvchange_resync(cmd, lv))
|
||||
return_ECMD_FAILED;
|
||||
|
||||
if (arg_count(cmd, syncaction_ARG) &&
|
||||
if (arg_is_set(cmd, syncaction_ARG) &&
|
||||
!lv_raid_message(lv, arg_str_value(cmd, syncaction_ARG, NULL)))
|
||||
return_ECMD_FAILED;
|
||||
|
||||
/* activation change */
|
||||
if (arg_count(cmd, activate_ARG)) {
|
||||
if (arg_is_set(cmd, activate_ARG)) {
|
||||
if (!_lvchange_activate(cmd, lv))
|
||||
return_ECMD_FAILED;
|
||||
} else if (arg_count(cmd, refresh_ARG)) {
|
||||
} else if (arg_is_set(cmd, refresh_ARG)) {
|
||||
if (!_lvchange_refresh(cmd, lv))
|
||||
return_ECMD_FAILED;
|
||||
} else {
|
||||
if (arg_count(cmd, monitor_ARG) &&
|
||||
if (arg_is_set(cmd, monitor_ARG) &&
|
||||
!_lvchange_monitoring(cmd, lv))
|
||||
return_ECMD_FAILED;
|
||||
|
||||
if (arg_count(cmd, poll_ARG) &&
|
||||
if (arg_is_set(cmd, poll_ARG) &&
|
||||
!_lvchange_background_polling(cmd, lv))
|
||||
return_ECMD_FAILED;
|
||||
}
|
||||
@ -1243,27 +1243,27 @@ int lvchange(struct cmd_context *cmd, int argc, char **argv)
|
||||
int update = update_partial_safe || update_partial_unsafe;
|
||||
|
||||
if (!update &&
|
||||
!arg_count(cmd, activate_ARG) && !arg_count(cmd, refresh_ARG) &&
|
||||
!arg_count(cmd, monitor_ARG) && !arg_count(cmd, poll_ARG)) {
|
||||
!arg_is_set(cmd, activate_ARG) && !arg_is_set(cmd, refresh_ARG) &&
|
||||
!arg_is_set(cmd, monitor_ARG) && !arg_is_set(cmd, poll_ARG)) {
|
||||
log_error("Need 1 or more of -a, -C, -M, -p, -r, -Z, "
|
||||
"--resync, --refresh, --alloc, --addtag, --deltag, "
|
||||
"--monitor, --poll or --discards");
|
||||
return EINVALID_CMD_LINE;
|
||||
}
|
||||
|
||||
if ((arg_count(cmd, profile_ARG) || arg_count(cmd, metadataprofile_ARG)) &&
|
||||
arg_count(cmd, detachprofile_ARG)) {
|
||||
if ((arg_is_set(cmd, profile_ARG) || arg_is_set(cmd, metadataprofile_ARG)) &&
|
||||
arg_is_set(cmd, detachprofile_ARG)) {
|
||||
log_error("Only one of --metadataprofile and --detachprofile permitted.");
|
||||
return EINVALID_CMD_LINE;
|
||||
}
|
||||
|
||||
if (arg_count(cmd, activate_ARG) && arg_count(cmd, refresh_ARG)) {
|
||||
if (arg_is_set(cmd, activate_ARG) && arg_is_set(cmd, refresh_ARG)) {
|
||||
log_error("Only one of -a and --refresh permitted.");
|
||||
return EINVALID_CMD_LINE;
|
||||
}
|
||||
|
||||
if ((arg_count(cmd, ignorelockingfailure_ARG) ||
|
||||
arg_count(cmd, sysinit_ARG)) && update) {
|
||||
if ((arg_is_set(cmd, ignorelockingfailure_ARG) ||
|
||||
arg_is_set(cmd, sysinit_ARG)) && update) {
|
||||
log_error("Only -a permitted with --ignorelockingfailure and --sysinit");
|
||||
return EINVALID_CMD_LINE;
|
||||
}
|
||||
@ -1276,23 +1276,23 @@ int lvchange(struct cmd_context *cmd, int argc, char **argv)
|
||||
return EINVALID_CMD_LINE;
|
||||
}
|
||||
|
||||
if ((arg_count(cmd, minor_ARG) || arg_count(cmd, major_ARG)) &&
|
||||
!arg_count(cmd, persistent_ARG)) {
|
||||
if ((arg_is_set(cmd, minor_ARG) || arg_is_set(cmd, major_ARG)) &&
|
||||
!arg_is_set(cmd, persistent_ARG)) {
|
||||
log_error("--major and --minor require -My");
|
||||
return EINVALID_CMD_LINE;
|
||||
}
|
||||
|
||||
if (arg_count(cmd, minor_ARG) && argc != 1) {
|
||||
if (arg_is_set(cmd, minor_ARG) && argc != 1) {
|
||||
log_error("Only give one logical volume when specifying minor");
|
||||
return EINVALID_CMD_LINE;
|
||||
}
|
||||
|
||||
if (arg_count(cmd, contiguous_ARG) && arg_count(cmd, alloc_ARG)) {
|
||||
if (arg_is_set(cmd, contiguous_ARG) && arg_is_set(cmd, alloc_ARG)) {
|
||||
log_error("Only one of --alloc and --contiguous permitted");
|
||||
return EINVALID_CMD_LINE;
|
||||
}
|
||||
|
||||
if (arg_count(cmd, poll_ARG) && arg_count(cmd, sysinit_ARG)) {
|
||||
if (arg_is_set(cmd, poll_ARG) && arg_is_set(cmd, sysinit_ARG)) {
|
||||
log_error("Only one of --poll and --sysinit permitted");
|
||||
return EINVALID_CMD_LINE;
|
||||
}
|
||||
@ -1304,7 +1304,7 @@ int lvchange(struct cmd_context *cmd, int argc, char **argv)
|
||||
* not neet to be running at this moment yet - it could be
|
||||
* just too early during system initialization time.
|
||||
*/
|
||||
if (arg_count(cmd, sysinit_ARG) && (arg_uint_value(cmd, activate_ARG, 0) == CHANGE_AAY)) {
|
||||
if (arg_is_set(cmd, sysinit_ARG) && (arg_uint_value(cmd, activate_ARG, 0) == CHANGE_AAY)) {
|
||||
if (lvmetad_used()) {
|
||||
log_warn("WARNING: lvmetad is active, skipping direct activation during sysinit");
|
||||
return ECMD_PROCESSED;
|
||||
@ -1324,7 +1324,7 @@ int lvchange(struct cmd_context *cmd, int argc, char **argv)
|
||||
* are cases where lvchange does not modify the vg, so they can use
|
||||
* the sh lock mode.
|
||||
*/
|
||||
if (arg_count(cmd, activate_ARG) || arg_count(cmd, refresh_ARG)) {
|
||||
if (arg_is_set(cmd, activate_ARG) || arg_is_set(cmd, refresh_ARG)) {
|
||||
cmd->lockd_vg_default_sh = 1;
|
||||
/* Allow deactivating if locks fail. */
|
||||
if (is_change_activating((activation_change_t)arg_uint_value(cmd, activate_ARG, CHANGE_AY)))
|
||||
|
@ -191,7 +191,7 @@ static int _lvconvert_name_params(struct lvconvert_params *lp,
|
||||
|
||||
if (!lp->merge_mirror &&
|
||||
!lp->repair &&
|
||||
!arg_count(cmd, splitmirrors_ARG) &&
|
||||
!arg_is_set(cmd, splitmirrors_ARG) &&
|
||||
!strstr(lp->lv_name, "_tdata") &&
|
||||
!strstr(lp->lv_name, "_tmeta") &&
|
||||
!strstr(lp->lv_name, "_cdata") &&
|
||||
@ -238,7 +238,7 @@ static int _check_conversion_type(struct cmd_context *cmd, const char *type_str)
|
||||
return 1;
|
||||
|
||||
if (!strcmp(type_str, "mirror")) {
|
||||
if (!arg_count(cmd, mirrors_ARG)) {
|
||||
if (!arg_is_set(cmd, mirrors_ARG)) {
|
||||
log_error("Conversions to --type mirror require -m/--mirrors");
|
||||
return 0;
|
||||
}
|
||||
@ -258,11 +258,11 @@ static int _check_conversion_type(struct cmd_context *cmd, const char *type_str)
|
||||
|
||||
/* -s/--snapshot and --type snapshot are synonyms */
|
||||
static int _snapshot_type_requested(struct cmd_context *cmd, const char *type_str) {
|
||||
return (arg_count(cmd, snapshot_ARG) || !strcmp(type_str, "snapshot"));
|
||||
return (arg_is_set(cmd, snapshot_ARG) || !strcmp(type_str, "snapshot"));
|
||||
}
|
||||
/* mirror/raid* (1,10,4,5,6 and their variants) reshape */
|
||||
static int _mirror_or_raid_type_requested(struct cmd_context *cmd, const char *type_str) {
|
||||
return (arg_count(cmd, mirrors_ARG) || !strncmp(type_str, "raid", 4) || !strcmp(type_str, "mirror"));
|
||||
return (arg_is_set(cmd, mirrors_ARG) || !strncmp(type_str, "raid", 4) || !strcmp(type_str, "mirror"));
|
||||
}
|
||||
|
||||
static int _read_pool_params(struct cmd_context *cmd, int *pargc, char ***pargv,
|
||||
@ -379,7 +379,7 @@ static int _read_params(struct cmd_context *cmd, int argc, char **argv,
|
||||
if (!_check_conversion_type(cmd, type_str))
|
||||
return_0;
|
||||
|
||||
if (arg_count(cmd, repair_ARG)) {
|
||||
if (arg_is_set(cmd, repair_ARG)) {
|
||||
if (arg_outside_list_is_set(cmd, "cannot be used with --repair",
|
||||
repair_ARG,
|
||||
alloc_ARG, usepolicies_ARG,
|
||||
@ -432,25 +432,25 @@ static int _read_params(struct cmd_context *cmd, int argc, char **argv,
|
||||
lp->uncache = 1;
|
||||
}
|
||||
|
||||
if ((_snapshot_type_requested(cmd, type_str) || arg_count(cmd, merge_ARG)) &&
|
||||
(arg_count(cmd, mirrorlog_ARG) || _mirror_or_raid_type_requested(cmd, type_str) ||
|
||||
lp->repair || arg_count(cmd, thinpool_ARG))) {
|
||||
if ((_snapshot_type_requested(cmd, type_str) || arg_is_set(cmd, merge_ARG)) &&
|
||||
(arg_is_set(cmd, mirrorlog_ARG) || _mirror_or_raid_type_requested(cmd, type_str) ||
|
||||
lp->repair || arg_is_set(cmd, thinpool_ARG))) {
|
||||
log_error("--snapshot/--type snapshot or --merge argument "
|
||||
"cannot be mixed with --mirrors/--type mirror/--type raid*, "
|
||||
"--mirrorlog, --repair or --thinpool.");
|
||||
return 0;
|
||||
}
|
||||
|
||||
if ((arg_count(cmd, stripes_long_ARG) || arg_count(cmd, stripesize_ARG)) &&
|
||||
if ((arg_is_set(cmd, stripes_long_ARG) || arg_is_set(cmd, stripesize_ARG)) &&
|
||||
!(_mirror_or_raid_type_requested(cmd, type_str) ||
|
||||
lp->repair ||
|
||||
arg_count(cmd, thinpool_ARG))) {
|
||||
arg_is_set(cmd, thinpool_ARG))) {
|
||||
log_error("--stripes or --stripesize argument is only valid "
|
||||
"with --mirrors/--type mirror/--type raid*, --repair and --thinpool");
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (arg_count(cmd, cache_ARG))
|
||||
if (arg_is_set(cmd, cache_ARG))
|
||||
lp->cache = 1;
|
||||
|
||||
if (!strcmp(type_str, "cache"))
|
||||
@ -463,7 +463,7 @@ static int _read_params(struct cmd_context *cmd, int argc, char **argv,
|
||||
type_str = "cache";
|
||||
}
|
||||
|
||||
if (arg_count(cmd, thin_ARG))
|
||||
if (arg_is_set(cmd, thin_ARG))
|
||||
lp->thin = 1;
|
||||
|
||||
if (!strcmp(type_str, "thin"))
|
||||
@ -479,11 +479,11 @@ static int _read_params(struct cmd_context *cmd, int argc, char **argv,
|
||||
if (!_read_pool_params(cmd, &argc, &argv, type_str, lp))
|
||||
return_0;
|
||||
|
||||
if (!arg_count(cmd, background_ARG))
|
||||
if (!arg_is_set(cmd, background_ARG))
|
||||
lp->wait_completion = 1;
|
||||
|
||||
if (_snapshot_type_requested(cmd, type_str)) {
|
||||
if (arg_count(cmd, merge_ARG)) {
|
||||
if (arg_is_set(cmd, merge_ARG)) {
|
||||
log_error("--snapshot and --merge are mutually exclusive.");
|
||||
return 0;
|
||||
}
|
||||
@ -499,14 +499,14 @@ static int _read_params(struct cmd_context *cmd, int argc, char **argv,
|
||||
* intent to keep the mimage that is detached, rather than
|
||||
* discarding it.
|
||||
*/
|
||||
} else if (arg_count(cmd, splitmirrors_ARG)) {
|
||||
} else if (arg_is_set(cmd, splitmirrors_ARG)) {
|
||||
if (_mirror_or_raid_type_requested(cmd, type_str)) {
|
||||
log_error("--mirrors/--type mirror/--type raid* and --splitmirrors are "
|
||||
"mutually exclusive.");
|
||||
return 0;
|
||||
}
|
||||
if (!arg_count(cmd, name_ARG) &&
|
||||
!arg_count(cmd, trackchanges_ARG)) {
|
||||
if (!arg_is_set(cmd, name_ARG) &&
|
||||
!arg_is_set(cmd, trackchanges_ARG)) {
|
||||
log_error("Please name the new logical volume using '--name'");
|
||||
return 0;
|
||||
}
|
||||
@ -515,20 +515,20 @@ static int _read_params(struct cmd_context *cmd, int argc, char **argv,
|
||||
lp->keep_mimages = 1;
|
||||
lp->mirrors = arg_uint_value(cmd, splitmirrors_ARG, 0);
|
||||
lp->mirrors_sign = SIGN_MINUS;
|
||||
} else if (arg_count(cmd, name_ARG)) {
|
||||
} else if (arg_is_set(cmd, name_ARG)) {
|
||||
log_error("The 'name' argument is only valid"
|
||||
" with --splitmirrors");
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (arg_count(cmd, merge_ARG)) {
|
||||
if (arg_is_set(cmd, merge_ARG)) {
|
||||
if ((argc == 1) && strstr(argv[0], "_rimage_"))
|
||||
lp->merge_mirror = 1;
|
||||
else
|
||||
lp->merge = 1;
|
||||
}
|
||||
|
||||
if (arg_count(cmd, mirrors_ARG)) {
|
||||
if (arg_is_set(cmd, mirrors_ARG)) {
|
||||
/*
|
||||
* --splitmirrors has been chosen as the mechanism for
|
||||
* specifying the intent of detaching and keeping a mimage
|
||||
@ -561,17 +561,17 @@ static int _read_params(struct cmd_context *cmd, int argc, char **argv,
|
||||
lp->origin_name = argv[0];
|
||||
argv++, argc--;
|
||||
|
||||
if (arg_count(cmd, regionsize_ARG)) {
|
||||
if (arg_is_set(cmd, regionsize_ARG)) {
|
||||
log_error("--regionsize is only available with mirrors");
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (arg_count(cmd, stripesize_ARG) || arg_count(cmd, stripes_long_ARG)) {
|
||||
if (arg_is_set(cmd, stripesize_ARG) || arg_is_set(cmd, stripes_long_ARG)) {
|
||||
log_error("--stripes and --stripesize are only available with striped mirrors");
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (arg_count(cmd, chunksize_ARG) &&
|
||||
if (arg_is_set(cmd, chunksize_ARG) &&
|
||||
(arg_sign_value(cmd, chunksize_ARG, SIGN_NONE) == SIGN_MINUS)) {
|
||||
log_error("Negative chunk size is invalid.");
|
||||
return 0;
|
||||
@ -592,7 +592,7 @@ static int _read_params(struct cmd_context *cmd, int argc, char **argv,
|
||||
lp->zero = (lp->segtype->flags & SEG_CANNOT_BE_ZEROED)
|
||||
? 0 : arg_int_value(cmd, zero_ARG, 1);
|
||||
|
||||
} else if (arg_count(cmd, replace_ARG)) { /* RAID device replacement */
|
||||
} else if (arg_is_set(cmd, replace_ARG)) { /* RAID device replacement */
|
||||
lp->replace_pv_count = arg_count(cmd, replace_ARG);
|
||||
lp->replace_pvs = dm_pool_alloc(cmd->mem, sizeof(char *) * lp->replace_pv_count);
|
||||
if (!lp->replace_pvs)
|
||||
@ -616,12 +616,12 @@ static int _read_params(struct cmd_context *cmd, int argc, char **argv,
|
||||
arg_is_set(cmd, repair_ARG) ||
|
||||
arg_is_set(cmd, mirrorlog_ARG) ||
|
||||
arg_is_set(cmd, corelog_ARG)) { /* Mirrors (and some RAID functions) */
|
||||
if (arg_count(cmd, chunksize_ARG)) {
|
||||
if (arg_is_set(cmd, chunksize_ARG)) {
|
||||
log_error("--chunksize is only available with snapshots or pools.");
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (arg_count(cmd, zero_ARG)) {
|
||||
if (arg_is_set(cmd, zero_ARG)) {
|
||||
log_error("--zero is only available with snapshots or thin pools.");
|
||||
return 0;
|
||||
}
|
||||
@ -631,7 +631,7 @@ static int _read_params(struct cmd_context *cmd, int argc, char **argv,
|
||||
* Checked when we know the state of the LV being converted.
|
||||
*/
|
||||
|
||||
if (arg_count(cmd, regionsize_ARG)) {
|
||||
if (arg_is_set(cmd, regionsize_ARG)) {
|
||||
if (arg_sign_value(cmd, regionsize_ARG, SIGN_NONE) ==
|
||||
SIGN_MINUS) {
|
||||
log_error("Negative regionsize is invalid");
|
||||
@ -671,12 +671,12 @@ static int _read_params(struct cmd_context *cmd, int argc, char **argv,
|
||||
if (!get_stripe_params(cmd, &lp->stripes, &lp->stripe_size))
|
||||
return_0;
|
||||
|
||||
if (arg_count(cmd, mirrors_ARG) && !lp->mirrors) {
|
||||
if (arg_is_set(cmd, mirrors_ARG) && !lp->mirrors) {
|
||||
/* down-converting to linear/stripe? */
|
||||
if (!(lp->segtype =
|
||||
get_segtype_from_string(cmd, SEG_TYPE_NAME_STRIPED)))
|
||||
return_0;
|
||||
} else if (arg_count(cmd, type_ARG)) {
|
||||
} else if (arg_is_set(cmd, type_ARG)) {
|
||||
/* changing mirror type? */
|
||||
if (!(lp->segtype = get_segtype_from_string(cmd, arg_str_value(cmd, type_ARG, find_config_tree_str(cmd, global_mirror_segtype_default_CFG, NULL)))))
|
||||
return_0;
|
||||
@ -945,7 +945,7 @@ static void _lvconvert_mirrors_repair_ask(struct cmd_context *cmd,
|
||||
int force = arg_count(cmd, force_ARG);
|
||||
int yes = arg_count(cmd, yes_ARG);
|
||||
|
||||
if (arg_count(cmd, usepolicies_ARG)) {
|
||||
if (arg_is_set(cmd, usepolicies_ARG)) {
|
||||
leg_policy = find_config_tree_str(cmd, activation_mirror_image_fault_policy_CFG, NULL);
|
||||
log_policy = find_config_tree_str(cmd, activation_mirror_log_fault_policy_CFG, NULL);
|
||||
*replace_mirrors = strcmp(leg_policy, "remove");
|
||||
@ -1139,7 +1139,7 @@ static int _lvconvert_mirrors_parse_params(struct cmd_context *cmd,
|
||||
*old_mimage_count = lv_mirror_count(lv);
|
||||
*old_log_count = _get_log_count(lv);
|
||||
|
||||
if (is_lockd_type(lv->vg->lock_type) && arg_count(cmd, splitmirrors_ARG)) {
|
||||
if (is_lockd_type(lv->vg->lock_type) && arg_is_set(cmd, splitmirrors_ARG)) {
|
||||
/* FIXME: we need to create a lock for the new LV. */
|
||||
log_error("Unable to split mirrors in VG with lock_type %s", lv->vg->lock_type);
|
||||
return 0;
|
||||
@ -1150,9 +1150,9 @@ static int _lvconvert_mirrors_parse_params(struct cmd_context *cmd,
|
||||
*
|
||||
* If called with no argument, try collapsing the resync layers
|
||||
*/
|
||||
if (!arg_count(cmd, mirrors_ARG) && !arg_count(cmd, mirrorlog_ARG) &&
|
||||
!arg_count(cmd, corelog_ARG) && !arg_count(cmd, regionsize_ARG) &&
|
||||
!arg_count(cmd, splitmirrors_ARG) && !lp->repair) {
|
||||
if (!arg_is_set(cmd, mirrors_ARG) && !arg_is_set(cmd, mirrorlog_ARG) &&
|
||||
!arg_is_set(cmd, corelog_ARG) && !arg_is_set(cmd, regionsize_ARG) &&
|
||||
!arg_is_set(cmd, splitmirrors_ARG) && !lp->repair) {
|
||||
*new_mimage_count = *old_mimage_count;
|
||||
*new_log_count = *old_log_count;
|
||||
|
||||
@ -1164,7 +1164,7 @@ static int _lvconvert_mirrors_parse_params(struct cmd_context *cmd,
|
||||
/*
|
||||
* Adjusting mimage count?
|
||||
*/
|
||||
if (!arg_count(cmd, mirrors_ARG) && !arg_count(cmd, splitmirrors_ARG))
|
||||
if (!arg_is_set(cmd, mirrors_ARG) && !arg_is_set(cmd, splitmirrors_ARG))
|
||||
lp->mirrors = *old_mimage_count;
|
||||
else if (lp->mirrors_sign == SIGN_PLUS)
|
||||
lp->mirrors = *old_mimage_count + lp->mirrors;
|
||||
@ -1207,7 +1207,7 @@ static int _lvconvert_mirrors_parse_params(struct cmd_context *cmd,
|
||||
* position that the user would like a 'disk' log.
|
||||
*/
|
||||
*new_log_count = (*old_mimage_count > 1) ? *old_log_count : 1;
|
||||
if (!arg_count(cmd, corelog_ARG) && !arg_count(cmd, mirrorlog_ARG))
|
||||
if (!arg_is_set(cmd, corelog_ARG) && !arg_is_set(cmd, mirrorlog_ARG))
|
||||
return 1;
|
||||
|
||||
*new_log_count = arg_int_value(cmd, mirrorlog_ARG,
|
||||
@ -1227,7 +1227,7 @@ static int _lvconvert_mirrors_parse_params(struct cmd_context *cmd,
|
||||
/*
|
||||
* Region size must not change on existing mirrors
|
||||
*/
|
||||
if (arg_count(cmd, regionsize_ARG) && lv_is_mirrored(lv) &&
|
||||
if (arg_is_set(cmd, regionsize_ARG) && lv_is_mirrored(lv) &&
|
||||
(lp->region_size != first_seg(lv)->region_size)) {
|
||||
log_error("Mirror log region size cannot be changed on "
|
||||
"an existing mirror.");
|
||||
@ -1395,7 +1395,7 @@ static int _lvconvert_mirrors_aux(struct cmd_context *cmd,
|
||||
|
||||
/* Reduce number of mirrors */
|
||||
if (lp->keep_mimages) {
|
||||
if (arg_count(cmd, trackchanges_ARG)) {
|
||||
if (arg_is_set(cmd, trackchanges_ARG)) {
|
||||
log_error("--trackchanges is not available "
|
||||
"to 'mirror' segment type");
|
||||
return 0;
|
||||
@ -1559,7 +1559,7 @@ static int _lvconvert_mirrors_repair(struct cmd_context *cmd,
|
||||
original_logs - _get_log_count(lv), original_logs,
|
||||
display_lvname(lv));
|
||||
|
||||
/* if (!arg_count(cmd, use_policies_ARG) && (lp->mirrors != old_mimage_count
|
||||
/* if (!arg_is_set(cmd, use_policies_ARG) && (lp->mirrors != old_mimage_count
|
||||
|| log_count != old_log_count))
|
||||
return 0; */
|
||||
|
||||
@ -1679,7 +1679,7 @@ static void _lvconvert_raid_repair_ask(struct cmd_context *cmd,
|
||||
|
||||
*replace_dev = 1;
|
||||
|
||||
if (arg_count(cmd, usepolicies_ARG)) {
|
||||
if (arg_is_set(cmd, usepolicies_ARG)) {
|
||||
dev_policy = find_config_tree_str(cmd, activation_raid_fault_policy_CFG, NULL);
|
||||
|
||||
if (!strcmp(dev_policy, "allocate") ||
|
||||
@ -1706,11 +1706,11 @@ static int _lvconvert_raid(struct logical_volume *lv, struct lvconvert_params *l
|
||||
struct lv_segment *seg = first_seg(lv);
|
||||
dm_percent_t sync_percent;
|
||||
|
||||
if (!arg_count(cmd, type_ARG))
|
||||
if (!arg_is_set(cmd, type_ARG))
|
||||
lp->segtype = seg->segtype;
|
||||
|
||||
/* Can only change image count for raid1 and linear */
|
||||
if (arg_count(cmd, mirrors_ARG) &&
|
||||
if (arg_is_set(cmd, mirrors_ARG) &&
|
||||
!seg_is_mirrored(seg) && !seg_is_linear(seg)) {
|
||||
log_error("'--mirrors/-m' is not compatible with %s",
|
||||
lvseg_name(seg));
|
||||
@ -1727,13 +1727,13 @@ static int _lvconvert_raid(struct logical_volume *lv, struct lvconvert_params *l
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (seg_is_linear(seg) && !lp->merge_mirror && !arg_count(cmd, mirrors_ARG)) {
|
||||
if (seg_is_linear(seg) && !lp->merge_mirror && !arg_is_set(cmd, mirrors_ARG)) {
|
||||
log_error("Raid conversions require -m/--mirrors");
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Change number of RAID1 images */
|
||||
if (arg_count(cmd, mirrors_ARG) || arg_count(cmd, splitmirrors_ARG)) {
|
||||
if (arg_is_set(cmd, mirrors_ARG) || arg_is_set(cmd, splitmirrors_ARG)) {
|
||||
image_count = lv_raid_image_count(lv);
|
||||
if (lp->mirrors_sign == SIGN_PLUS)
|
||||
image_count += lp->mirrors;
|
||||
@ -1744,7 +1744,7 @@ static int _lvconvert_raid(struct logical_volume *lv, struct lvconvert_params *l
|
||||
|
||||
if (image_count < 1) {
|
||||
log_error("Unable to %s images by specified amount",
|
||||
arg_count(cmd, splitmirrors_ARG) ?
|
||||
arg_is_set(cmd, splitmirrors_ARG) ?
|
||||
"split" : "reduce");
|
||||
return 0;
|
||||
}
|
||||
@ -1753,20 +1753,20 @@ static int _lvconvert_raid(struct logical_volume *lv, struct lvconvert_params *l
|
||||
if (lp->merge_mirror)
|
||||
return lv_raid_merge(lv);
|
||||
|
||||
if (arg_count(cmd, trackchanges_ARG))
|
||||
if (arg_is_set(cmd, trackchanges_ARG))
|
||||
return lv_raid_split_and_track(lv, lp->pvh);
|
||||
|
||||
if (arg_count(cmd, splitmirrors_ARG))
|
||||
if (arg_is_set(cmd, splitmirrors_ARG))
|
||||
return lv_raid_split(lv, lp->lv_split_name,
|
||||
image_count, lp->pvh);
|
||||
|
||||
if (arg_count(cmd, mirrors_ARG))
|
||||
if (arg_is_set(cmd, mirrors_ARG))
|
||||
return lv_raid_change_image_count(lv, image_count, lp->pvh);
|
||||
|
||||
if (arg_count(cmd, type_ARG))
|
||||
if (arg_is_set(cmd, type_ARG))
|
||||
return lv_raid_reshape(lv, lp->segtype);
|
||||
|
||||
if (arg_count(cmd, replace_ARG))
|
||||
if (arg_is_set(cmd, replace_ARG))
|
||||
return lv_raid_replace(lv, lp->replace_pvh, lp->pvh);
|
||||
|
||||
if (lp->repair) {
|
||||
@ -1815,7 +1815,7 @@ static int _lvconvert_raid(struct logical_volume *lv, struct lvconvert_params *l
|
||||
}
|
||||
|
||||
/* "warn" if policy not set to replace */
|
||||
if (arg_count(cmd, usepolicies_ARG))
|
||||
if (arg_is_set(cmd, usepolicies_ARG))
|
||||
log_warn("Use 'lvconvert --repair %s/%s' to replace "
|
||||
"failed device.", lv->vg->name, lv->name);
|
||||
return 1;
|
||||
@ -2905,7 +2905,7 @@ static int _lvconvert_pool(struct cmd_context *cmd,
|
||||
seg = first_seg(pool_lv);
|
||||
|
||||
/* Normally do NOT change chunk size when swapping */
|
||||
if (arg_count(cmd, chunksize_ARG) &&
|
||||
if (arg_is_set(cmd, chunksize_ARG) &&
|
||||
(lp->chunk_size != seg->chunk_size) &&
|
||||
!dm_list_empty(&pool_lv->segs_using_this_lv)) {
|
||||
if (lp->force == PROMPT) {
|
||||
@ -2934,9 +2934,9 @@ static int _lvconvert_pool(struct cmd_context *cmd,
|
||||
if (metadata_lv->le_count < lp->pool_metadata_extents)
|
||||
log_print_unless_silent("Continuing with swap...");
|
||||
|
||||
if (!arg_count(cmd, discards_ARG))
|
||||
if (!arg_is_set(cmd, discards_ARG))
|
||||
lp->discards = seg->discards;
|
||||
if (!arg_count(cmd, zero_ARG))
|
||||
if (!arg_is_set(cmd, zero_ARG))
|
||||
lp->zero = seg->zero_new_blocks;
|
||||
|
||||
if (!lp->yes &&
|
||||
@ -3321,7 +3321,7 @@ static int _lvconvert(struct cmd_context *cmd, struct logical_volume *lv,
|
||||
return ECMD_PROCESSED;
|
||||
}
|
||||
if (!lv_is_mirrored(lv) && !lv_is_raid(lv)) {
|
||||
if (arg_count(cmd, usepolicies_ARG))
|
||||
if (arg_is_set(cmd, usepolicies_ARG))
|
||||
return ECMD_PROCESSED; /* nothing to be done here */
|
||||
log_error("Cannot repair logical volume %s of segtype %s.",
|
||||
display_lvname(lv), lvseg_name(first_seg(lv)));
|
||||
@ -3331,7 +3331,7 @@ static int _lvconvert(struct cmd_context *cmd, struct logical_volume *lv,
|
||||
|
||||
/* forward splitmirror operations to the cache origin, which may be raid
|
||||
* or old-style mirror */
|
||||
if (arg_count(cmd, splitmirrors_ARG) && lv_is_cache_type(lv)
|
||||
if (arg_is_set(cmd, splitmirrors_ARG) && lv_is_cache_type(lv)
|
||||
&& (origin = seg_lv(first_seg(lv), 0)) && lv_is_cache_origin(origin)) {
|
||||
log_warn("WARNING: Selected operation does not work with cache-type LVs.");
|
||||
log_warn("WARNING: Proceeding using the cache origin volume %s instead.",
|
||||
@ -3348,7 +3348,7 @@ static int _lvconvert(struct cmd_context *cmd, struct logical_volume *lv,
|
||||
* the segtype was not specified, then we need
|
||||
* to consult the default.
|
||||
*/
|
||||
if (arg_count(cmd, mirrors_ARG) && !lv_is_mirrored(lv)) {
|
||||
if (arg_is_set(cmd, mirrors_ARG) && !lv_is_mirrored(lv)) {
|
||||
if (!(lp->segtype = get_segtype_from_string(cmd, find_config_tree_str(cmd, global_mirror_segtype_default_CFG, NULL))))
|
||||
return_ECMD_FAILED;
|
||||
}
|
||||
@ -3382,10 +3382,10 @@ static int _lvconvert(struct cmd_context *cmd, struct logical_volume *lv,
|
||||
return_ECMD_FAILED;
|
||||
|
||||
/* If repairing and using policies, remove missing PVs from VG */
|
||||
if (lp->repair && arg_count(cmd, usepolicies_ARG))
|
||||
if (lp->repair && arg_is_set(cmd, usepolicies_ARG))
|
||||
_remove_missing_empty_pv(lv->vg, failed_pvs);
|
||||
} else if (arg_count(cmd, mirrors_ARG) ||
|
||||
arg_count(cmd, splitmirrors_ARG) ||
|
||||
} else if (arg_is_set(cmd, mirrors_ARG) ||
|
||||
arg_is_set(cmd, splitmirrors_ARG) ||
|
||||
lv_is_mirrored(lv)) {
|
||||
if (!archive(lv->vg))
|
||||
return_ECMD_FAILED;
|
||||
@ -3397,7 +3397,7 @@ static int _lvconvert(struct cmd_context *cmd, struct logical_volume *lv,
|
||||
return_ECMD_FAILED;
|
||||
|
||||
/* If repairing and using policies, remove missing PVs from VG */
|
||||
if (lp->repair && arg_count(cmd, usepolicies_ARG))
|
||||
if (lp->repair && arg_is_set(cmd, usepolicies_ARG))
|
||||
_remove_missing_empty_pv(lv->vg, failed_pvs);
|
||||
}
|
||||
|
||||
|
@ -131,7 +131,7 @@ static int _lvcreate_name_params(struct cmd_context *cmd,
|
||||
"in one command is not yet supported.");
|
||||
return 0;
|
||||
}
|
||||
} else if (lp->snapshot && !arg_count(cmd, virtualsize_ARG)) {
|
||||
} else if (lp->snapshot && !arg_is_set(cmd, virtualsize_ARG)) {
|
||||
/* argv[0] might be [vg/]origin */
|
||||
if (!argc) {
|
||||
log_error("Please specify a logical volume to act as "
|
||||
@ -414,14 +414,14 @@ static int _read_size_params(struct cmd_context *cmd,
|
||||
|
||||
lcp->virtual_size = arg_uint64_value(cmd, virtualsize_ARG, UINT64_C(0));
|
||||
|
||||
if (arg_count(cmd, extents_ARG)) {
|
||||
if (arg_count(cmd, size_ARG)) {
|
||||
if (arg_is_set(cmd, extents_ARG)) {
|
||||
if (arg_is_set(cmd, size_ARG)) {
|
||||
log_error("Please specify either size or extents (not both).");
|
||||
return 0;
|
||||
}
|
||||
lp->extents = arg_uint_value(cmd, extents_ARG, 0);
|
||||
lcp->percent = arg_percent_value(cmd, extents_ARG, PERCENT_NONE);
|
||||
} else if (arg_count(cmd, size_ARG)) {
|
||||
} else if (arg_is_set(cmd, size_ARG)) {
|
||||
lcp->size = arg_uint64_value(cmd, size_ARG, UINT64_C(0));
|
||||
lcp->percent = PERCENT_NONE;
|
||||
} else if (!lp->snapshot && !seg_is_thin_volume(lp)) {
|
||||
@ -459,7 +459,7 @@ static int _read_raid_params(struct cmd_context *cmd,
|
||||
struct lvcreate_params *lp)
|
||||
{
|
||||
if ((lp->stripes < 2) && segtype_is_raid10(lp->segtype)) {
|
||||
if (arg_count(cmd, stripes_ARG)) {
|
||||
if (arg_is_set(cmd, stripes_ARG)) {
|
||||
/* User supplied the bad argument */
|
||||
log_error("Segment type 'raid10' requires 2 or more stripes.");
|
||||
return 0;
|
||||
@ -479,7 +479,7 @@ static int _read_raid_params(struct cmd_context *cmd,
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (arg_count(cmd, mirrors_ARG) && segtype_is_raid(lp->segtype) &&
|
||||
if (arg_is_set(cmd, mirrors_ARG) && segtype_is_raid(lp->segtype) &&
|
||||
!segtype_is_raid1(lp->segtype) && !segtype_is_raid10(lp->segtype)) {
|
||||
log_error("Mirror argument cannot be used with segment type, %s",
|
||||
lp->segtype->name);
|
||||
@ -509,7 +509,7 @@ static int _read_mirror_and_raid_params(struct cmd_context *cmd,
|
||||
const char *segtype_name;
|
||||
|
||||
/* Common mirror and raid params */
|
||||
if (arg_count(cmd, mirrors_ARG)) {
|
||||
if (arg_is_set(cmd, mirrors_ARG)) {
|
||||
lp->mirrors = arg_uint_value(cmd, mirrors_ARG, 0) + 1;
|
||||
if (segtype_is_raid1(lp->segtype)) {
|
||||
segtype_name = SEG_TYPE_NAME_RAID1;
|
||||
@ -1228,7 +1228,7 @@ static int _check_raid_parameters(struct volume_group *vg,
|
||||
* If number of devices was not supplied, we can infer from
|
||||
* the PVs given.
|
||||
*/
|
||||
if (!arg_count(cmd, stripes_ARG) &&
|
||||
if (!arg_is_set(cmd, stripes_ARG) &&
|
||||
(devs > 2 * lp->segtype->parity_devs))
|
||||
lp->stripes = devs - lp->segtype->parity_devs;
|
||||
|
||||
@ -1239,7 +1239,7 @@ static int _check_raid_parameters(struct volume_group *vg,
|
||||
return 0;
|
||||
}
|
||||
} else if (segtype_is_raid10(lp->segtype)) {
|
||||
if (!arg_count(cmd, stripes_ARG))
|
||||
if (!arg_is_set(cmd, stripes_ARG))
|
||||
lp->stripes = devs / lp->mirrors;
|
||||
if (lp->stripes < 2) {
|
||||
log_error("Unable to create RAID10 LV,"
|
||||
|
@ -18,14 +18,14 @@
|
||||
static int _lvdisplay_single(struct cmd_context *cmd, struct logical_volume *lv,
|
||||
struct processing_handle *handle __attribute__ ((unused)))
|
||||
{
|
||||
if (!arg_count(cmd, all_ARG) && !lv_is_visible(lv))
|
||||
if (!arg_is_set(cmd, all_ARG) && !lv_is_visible(lv))
|
||||
return ECMD_PROCESSED;
|
||||
|
||||
if (arg_count(cmd, colon_ARG))
|
||||
if (arg_is_set(cmd, colon_ARG))
|
||||
lvdisplay_colons(lv);
|
||||
else {
|
||||
lvdisplay_full(cmd, lv, NULL);
|
||||
if (arg_count(cmd, maps_ARG))
|
||||
if (arg_is_set(cmd, maps_ARG))
|
||||
lvdisplay_segments(lv);
|
||||
}
|
||||
|
||||
@ -34,26 +34,26 @@ static int _lvdisplay_single(struct cmd_context *cmd, struct logical_volume *lv,
|
||||
|
||||
int lvdisplay(struct cmd_context *cmd, int argc, char **argv)
|
||||
{
|
||||
if (arg_count(cmd, columns_ARG)) {
|
||||
if (arg_count(cmd, colon_ARG) || arg_count(cmd, maps_ARG)) {
|
||||
if (arg_is_set(cmd, columns_ARG)) {
|
||||
if (arg_is_set(cmd, colon_ARG) || arg_is_set(cmd, maps_ARG)) {
|
||||
log_error("Incompatible options selected");
|
||||
return EINVALID_CMD_LINE;
|
||||
}
|
||||
return lvs(cmd, argc, argv);
|
||||
}
|
||||
|
||||
if (arg_count(cmd, aligned_ARG) ||
|
||||
arg_count(cmd, binary_ARG) ||
|
||||
arg_count(cmd, noheadings_ARG) ||
|
||||
arg_count(cmd, options_ARG) ||
|
||||
arg_count(cmd, separator_ARG) ||
|
||||
arg_count(cmd, sort_ARG) ||
|
||||
arg_count(cmd, unbuffered_ARG)) {
|
||||
if (arg_is_set(cmd, aligned_ARG) ||
|
||||
arg_is_set(cmd, binary_ARG) ||
|
||||
arg_is_set(cmd, noheadings_ARG) ||
|
||||
arg_is_set(cmd, options_ARG) ||
|
||||
arg_is_set(cmd, separator_ARG) ||
|
||||
arg_is_set(cmd, sort_ARG) ||
|
||||
arg_is_set(cmd, unbuffered_ARG)) {
|
||||
log_error("Incompatible options selected.");
|
||||
return EINVALID_CMD_LINE;
|
||||
}
|
||||
|
||||
if (arg_count(cmd, colon_ARG) && arg_count(cmd, maps_ARG)) {
|
||||
if (arg_is_set(cmd, colon_ARG) && arg_is_set(cmd, maps_ARG)) {
|
||||
log_error("Options -c and -m are incompatible.");
|
||||
return EINVALID_CMD_LINE;
|
||||
}
|
||||
|
@ -82,7 +82,7 @@ int arg_from_list_is_set(const struct cmd_context *cmd, const char *err_found, .
|
||||
va_list ap;
|
||||
|
||||
va_start(ap, err_found);
|
||||
while ((arg = va_arg(ap, int)) != -1 && !arg_count(cmd, arg))
|
||||
while ((arg = va_arg(ap, int)) != -1 && !arg_is_set(cmd, arg))
|
||||
/* empty */;
|
||||
va_end(ap);
|
||||
|
||||
@ -116,7 +116,7 @@ int arg_outside_list_is_set(const struct cmd_context *cmd, const char *err_found
|
||||
case yes_ARG:
|
||||
continue;
|
||||
}
|
||||
if (!arg_count(cmd, i))
|
||||
if (!arg_is_set(cmd, i))
|
||||
continue; /* unset */
|
||||
va_start(ap, err_found);
|
||||
while |