1
0
mirror of git://sourceware.org/git/lvm2.git synced 2025-03-10 16:58:47 +03:00

lvchange: use better arg functions

This commit is contained in:
Zdenek Kabelac 2016-04-26 22:04:19 +02:00
parent c215e1be5c
commit e77b6968b6

View File

@ -911,21 +911,32 @@ static int _lvchange_single(struct cmd_context *cmd, struct logical_volume *lv,
return_ECMD_FAILED;
if (!(lv->vg->status & LVM_WRITE) &&
(arg_count(cmd, contiguous_ARG) || arg_count(cmd, permission_ARG) ||
arg_count(cmd, readahead_ARG) || arg_count(cmd, persistent_ARG) ||
arg_count(cmd, discards_ARG) || arg_count(cmd, zero_ARG) ||
arg_count(cmd, alloc_ARG) || arg_count(cmd, profile_ARG) ||
arg_count(cmd, metadataprofile_ARG))) {
arg_from_list_is_set(cmd, NULL,
alloc_ARG,
contiguous_ARG,
discards_ARG,
metadataprofile_ARG,
permission_ARG,
persistent_ARG,
profile_ARG,
readahead_ARG,
zero_ARG,
-1)) {
log_error("Only -a permitted with read-only volume "
"group \"%s\"", lv->vg->name);
return ECMD_FAILED;
}
if (lv_is_origin(lv) && !lv_is_thin_volume(lv) &&
(arg_count(cmd, contiguous_ARG) || arg_count(cmd, permission_ARG) ||
arg_count(cmd, readahead_ARG) || arg_count(cmd, persistent_ARG) ||
arg_count(cmd, alloc_ARG) || arg_count(cmd, profile_ARG) ||
arg_count(cmd, metadataprofile_ARG))) {
arg_from_list_is_set(cmd, NULL,
alloc_ARG,
contiguous_ARG,
metadataprofile_ARG,
permission_ARG,
persistent_ARG,
profile_ARG,
readahead_ARG,
-1)) {
log_error("Can't change logical volume \"%s\" under snapshot",
lv->name);
return ECMD_FAILED;
@ -1173,29 +1184,33 @@ int lvchange(struct cmd_context *cmd, int argc, char **argv)
* --monitor or --poll).
*/
int update_partial_safe = /* options safe to update if partial */
arg_count(cmd, contiguous_ARG) ||
arg_count(cmd, permission_ARG) ||
arg_count(cmd, readahead_ARG) ||
arg_count(cmd, persistent_ARG) ||
arg_count(cmd, addtag_ARG) ||
arg_count(cmd, deltag_ARG) ||
arg_count(cmd, metadataprofile_ARG) ||
arg_count(cmd, profile_ARG) ||
arg_count(cmd, detachprofile_ARG) ||
arg_count(cmd, setactivationskip_ARG);
arg_from_list_is_set(cmd, NULL,
addtag_ARG,
contiguous_ARG,
deltag_ARG,
detachprofile_ARG,
metadataprofile_ARG,
permission_ARG,
persistent_ARG,
profile_ARG,
readahead_ARG,
setactivationskip_ARG,
-1);
int update_partial_unsafe =
arg_count(cmd, alloc_ARG) ||
arg_count(cmd, discards_ARG) ||
arg_count(cmd, errorwhenfull_ARG) ||
arg_count(cmd, minrecoveryrate_ARG) ||
arg_count(cmd, maxrecoveryrate_ARG) ||
arg_count(cmd, resync_ARG) ||
arg_count(cmd, syncaction_ARG) ||
arg_count(cmd, cachepolicy_ARG) ||
arg_count(cmd, cachesettings_ARG) ||
arg_count(cmd, writebehind_ARG) ||
arg_count(cmd, writemostly_ARG) ||
arg_count(cmd, zero_ARG);
arg_from_list_is_set(cmd, NULL,
alloc_ARG,
cachepolicy_ARG,
cachesettings_ARG,
discards_ARG,
errorwhenfull_ARG,
maxrecoveryrate_ARG,
minrecoveryrate_ARG,
resync_ARG,
syncaction_ARG,
writebehind_ARG,
writemostly_ARG,
zero_ARG,
-1);
int update = update_partial_safe || update_partial_unsafe;
if (!update &&