mirror of
git://sourceware.org/git/lvm2.git
synced 2025-01-03 05:18:29 +03:00
tools: read yes_no_arg via int_value
yes_no_arg is already parsed so read parsed value as int.
This commit is contained in:
parent
5bdf48b489
commit
237c54802c
@ -461,12 +461,10 @@ static int lvchange_resync(struct cmd_context *cmd, struct logical_volume *lv)
|
|||||||
|
|
||||||
static int lvchange_alloc(struct cmd_context *cmd, struct logical_volume *lv)
|
static int lvchange_alloc(struct cmd_context *cmd, struct logical_volume *lv)
|
||||||
{
|
{
|
||||||
int want_contiguous = 0;
|
int want_contiguous = arg_int_value(cmd, contiguous_ARG, 0);
|
||||||
alloc_policy_t alloc;
|
alloc_policy_t alloc = (alloc_policy_t)
|
||||||
|
arg_uint_value(cmd, alloc_ARG, (want_contiguous)
|
||||||
want_contiguous = strcmp(arg_str_value(cmd, contiguous_ARG, "n"), "n");
|
? ALLOC_CONTIGUOUS : ALLOC_INHERIT);
|
||||||
alloc = want_contiguous ? ALLOC_CONTIGUOUS : ALLOC_INHERIT;
|
|
||||||
alloc = (alloc_policy_t) arg_uint_value(cmd, alloc_ARG, alloc);
|
|
||||||
|
|
||||||
if (alloc == lv->alloc) {
|
if (alloc == lv->alloc) {
|
||||||
log_error("Allocation policy of logical volume \"%s\" is "
|
log_error("Allocation policy of logical volume \"%s\" is "
|
||||||
|
@ -559,10 +559,8 @@ static int _read_params(struct lvconvert_params *lp, struct cmd_context *cmd,
|
|||||||
if (!(lp->segtype = get_segtype_from_string(cmd, "snapshot")))
|
if (!(lp->segtype = get_segtype_from_string(cmd, "snapshot")))
|
||||||
return_0;
|
return_0;
|
||||||
|
|
||||||
lp->zero = strcmp(arg_str_value(cmd, zero_ARG,
|
lp->zero = (lp->segtype->flags & SEG_CANNOT_BE_ZEROED)
|
||||||
(lp->segtype->flags &
|
? 0 : arg_int_value(cmd, zero_ARG, 1);
|
||||||
SEG_CANNOT_BE_ZEROED) ?
|
|
||||||
"n" : "y"), "n");
|
|
||||||
|
|
||||||
} else if (arg_count(cmd, replace_ARG)) { /* RAID device replacement */
|
} else if (arg_count(cmd, replace_ARG)) { /* RAID device replacement */
|
||||||
lp->replace_pv_count = arg_count(cmd, replace_ARG);
|
lp->replace_pv_count = arg_count(cmd, replace_ARG);
|
||||||
|
@ -985,13 +985,13 @@ static int _lvcreate_params(struct lvcreate_params *lp,
|
|||||||
/*
|
/*
|
||||||
* Should we zero/wipe signatures on the lv.
|
* Should we zero/wipe signatures on the lv.
|
||||||
*/
|
*/
|
||||||
lp->zero = (!(lp->segtype->flags & SEG_CANNOT_BE_ZEROED) &&
|
lp->zero = (lp->segtype->flags & SEG_CANNOT_BE_ZEROED)
|
||||||
(strcmp(arg_str_value(cmd, zero_ARG, "y"), "y") == 0)) ? 1 : 0;
|
? 0 : arg_int_value(cmd, zero_ARG, 1);
|
||||||
|
|
||||||
if (arg_count(cmd, wipesignatures_ARG)) {
|
if (arg_count(cmd, wipesignatures_ARG)) {
|
||||||
/* If -W/--wipesignatures is given on command line directly, respect it. */
|
/* If -W/--wipesignatures is given on command line directly, respect it. */
|
||||||
lp->wipe_signatures =(!(lp->segtype->flags & SEG_CANNOT_BE_ZEROED) &&
|
lp->wipe_signatures = (lp->segtype->flags & SEG_CANNOT_BE_ZEROED)
|
||||||
(strcmp(arg_str_value(cmd, wipesignatures_ARG, "y"), "y") == 0)) ? 1 : 0;
|
? 0 : arg_int_value(cmd, wipesignatures_ARG, 1);
|
||||||
} else {
|
} else {
|
||||||
/*
|
/*
|
||||||
* If -W/--wipesignatures is not given on command line,
|
* If -W/--wipesignatures is not given on command line,
|
||||||
@ -1047,7 +1047,7 @@ static int _lvcreate_params(struct lvcreate_params *lp,
|
|||||||
/*
|
/*
|
||||||
* Allocation parameters
|
* Allocation parameters
|
||||||
*/
|
*/
|
||||||
contiguous = strcmp(arg_str_value(cmd, contiguous_ARG, "n"), "n");
|
contiguous = arg_int_value(cmd, contiguous_ARG, 0);
|
||||||
|
|
||||||
lp->alloc = contiguous ? ALLOC_CONTIGUOUS : ALLOC_INHERIT;
|
lp->alloc = contiguous ? ALLOC_CONTIGUOUS : ALLOC_INHERIT;
|
||||||
|
|
||||||
|
@ -22,18 +22,9 @@ static int _pvchange_single(struct cmd_context *cmd, struct volume_group *vg,
|
|||||||
const char *pv_name = pv_dev_name(pv);
|
const char *pv_name = pv_dev_name(pv);
|
||||||
char uuid[64] __attribute__((aligned(8)));
|
char uuid[64] __attribute__((aligned(8)));
|
||||||
|
|
||||||
int allocatable = 0;
|
int allocatable = arg_int_value(cmd, allocatable_ARG, 0);
|
||||||
int tagargs = 0;
|
int mda_ignore = arg_int_value(cmd, metadataignore_ARG, 0);
|
||||||
int mda_ignore = 0;
|
int tagargs = arg_count(cmd, addtag_ARG) + arg_count(cmd, deltag_ARG);
|
||||||
|
|
||||||
tagargs = arg_count(cmd, addtag_ARG) + arg_count(cmd, deltag_ARG);
|
|
||||||
|
|
||||||
if (arg_count(cmd, allocatable_ARG))
|
|
||||||
allocatable = !strcmp(arg_str_value(cmd, allocatable_ARG, "n"),
|
|
||||||
"y");
|
|
||||||
if (arg_count(cmd, metadataignore_ARG))
|
|
||||||
mda_ignore = !strcmp(arg_str_value(cmd, metadataignore_ARG, "n"),
|
|
||||||
"y");
|
|
||||||
|
|
||||||
/* If in a VG, must change using volume group. */
|
/* If in a VG, must change using volume group. */
|
||||||
if (!is_orphan(pv)) {
|
if (!is_orphan(pv)) {
|
||||||
|
@ -643,9 +643,7 @@ int vgcreate_params_set_from_args(struct cmd_context *cmd,
|
|||||||
arg_uint_value(cmd, physicalextentsize_ARG, vp_def->extent_size);
|
arg_uint_value(cmd, physicalextentsize_ARG, vp_def->extent_size);
|
||||||
|
|
||||||
if (arg_count(cmd, clustered_ARG))
|
if (arg_count(cmd, clustered_ARG))
|
||||||
vp_new->clustered =
|
vp_new->clustered = arg_int_value(cmd, clustered_ARG, vp_def->clustered);
|
||||||
!strcmp(arg_str_value(cmd, clustered_ARG,
|
|
||||||
vp_def->clustered ? "y":"n"), "y");
|
|
||||||
else
|
else
|
||||||
/* Default depends on current locking type */
|
/* Default depends on current locking type */
|
||||||
vp_new->clustered = locking_is_clustered();
|
vp_new->clustered = locking_is_clustered();
|
||||||
@ -866,8 +864,7 @@ int pvcreate_params_validate(struct cmd_context *cmd,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (arg_count(cmd, zero_ARG))
|
pp->zero = arg_int_value(cmd, zero_ARG, 1);
|
||||||
pp->zero = strcmp(arg_str_value(cmd, zero_ARG, "y"), "n");
|
|
||||||
|
|
||||||
if (arg_sign_value(cmd, dataalignment_ARG, SIGN_NONE) == SIGN_MINUS) {
|
if (arg_sign_value(cmd, dataalignment_ARG, SIGN_NONE) == SIGN_MINUS) {
|
||||||
log_error("Physical volume data alignment may not be negative");
|
log_error("Physical volume data alignment may not be negative");
|
||||||
@ -966,7 +963,7 @@ int get_pool_params(struct cmd_context *cmd,
|
|||||||
if (segtype_is_thin_pool(segtype) || segtype_is_thin(segtype)) {
|
if (segtype_is_thin_pool(segtype) || segtype_is_thin(segtype)) {
|
||||||
if (arg_count(cmd, zero_ARG)) {
|
if (arg_count(cmd, zero_ARG)) {
|
||||||
*passed_args |= PASS_ARG_ZERO;
|
*passed_args |= PASS_ARG_ZERO;
|
||||||
*zero = strcmp(arg_str_value(cmd, zero_ARG, "y"), "n");
|
*zero = arg_int_value(cmd, zero_ARG, 1);
|
||||||
log_very_verbose("Setting pool zeroing: %u", *zero);
|
log_very_verbose("Setting pool zeroing: %u", *zero);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1188,7 +1185,7 @@ int get_and_validate_major_minor(const struct cmd_context *cmd,
|
|||||||
const struct format_type *fmt,
|
const struct format_type *fmt,
|
||||||
int32_t *major, int32_t *minor)
|
int32_t *major, int32_t *minor)
|
||||||
{
|
{
|
||||||
if (strcmp(arg_str_value(cmd, persistent_ARG, "n"), "y")) {
|
if (!arg_int_value(cmd, persistent_ARG, 0)) {
|
||||||
if (arg_is_set(cmd, minor_ARG) || arg_is_set(cmd, major_ARG)) {
|
if (arg_is_set(cmd, minor_ARG) || arg_is_set(cmd, major_ARG)) {
|
||||||
log_error("--major and --minor incompatible with -Mn");
|
log_error("--major and --minor incompatible with -Mn");
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -278,7 +278,7 @@ static int _vgchange_alloc(struct cmd_context *cmd, struct volume_group *vg)
|
|||||||
static int _vgchange_resizeable(struct cmd_context *cmd,
|
static int _vgchange_resizeable(struct cmd_context *cmd,
|
||||||
struct volume_group *vg)
|
struct volume_group *vg)
|
||||||
{
|
{
|
||||||
int resizeable = !strcmp(arg_str_value(cmd, resizeable_ARG, "n"), "y");
|
int resizeable = arg_int_value(cmd, resizeable_ARG, 0);
|
||||||
|
|
||||||
if (resizeable && vg_is_resizeable(vg)) {
|
if (resizeable && vg_is_resizeable(vg)) {
|
||||||
log_error("Volume group \"%s\" is already resizeable",
|
log_error("Volume group \"%s\" is already resizeable",
|
||||||
@ -303,7 +303,7 @@ static int _vgchange_resizeable(struct cmd_context *cmd,
|
|||||||
static int _vgchange_clustered(struct cmd_context *cmd,
|
static int _vgchange_clustered(struct cmd_context *cmd,
|
||||||
struct volume_group *vg)
|
struct volume_group *vg)
|
||||||
{
|
{
|
||||||
int clustered = !strcmp(arg_str_value(cmd, clustered_ARG, "n"), "y");
|
int clustered = arg_int_value(cmd, clustered_ARG, 0);
|
||||||
|
|
||||||
if (clustered && (vg_is_clustered(vg))) {
|
if (clustered && (vg_is_clustered(vg))) {
|
||||||
log_error("Volume group \"%s\" is already clustered",
|
log_error("Volume group \"%s\" is already clustered",
|
||||||
|
Loading…
Reference in New Issue
Block a user