1
0
mirror of git://sourceware.org/git/lvm2.git synced 2025-09-26 01:44:19 +03:00

Compare commits

..

1 Commits

Author SHA1 Message Date
David Teigland
9d5d52b35e commands: new method for defining commands 2016-10-05 14:52:32 -05:00
11 changed files with 4271 additions and 3542 deletions

View File

@@ -89,7 +89,7 @@ struct cmd_context {
*/
const char *cmd_line;
struct command *command;
char **pos_arg_values;
char **argv;
struct arg_values *opt_arg_values;
struct dm_list arg_value_groups;

View File

@@ -7,6 +7,8 @@
# scripts/create-commands --output struct scripts/command-lines.in > tools/command-lines.h
#
#
# Syntax
#
# A new command has a unique combination of:
# command name, required option args and required
@@ -52,7 +54,8 @@
# it is followed by ..., e.g. VG|LV|Tag ...
#
# LV can have a suffix indicating the LV type, e.g. LV_linear, LV_thinpool.
# LV_raid represents any raidN.
# LV_raid represents any raidN. LV_type1_type2_type3 when the LV is
# limited to multiple specific types.
#
# VG, LV can have the suffix _new, indicating the named VG or LV
# does not yet exist.
@@ -60,6 +63,33 @@
# If Select is included in pos_arg, it means that the pos_arg
# may be empty if the --select option is used.
#
# --size and --extents are interchangable, but only --size is used
# in these definitions to keep them simpler. Either --size or
# --extents will be recognized when matching a command to one of
# these definitions.
#
# Some options have multiple names, but only one form of the name
# is used in these definitions. Synonyms will be recognized when
# matching a command to a command definition.
#
# used in definitions below (equivalent but not used in definitions)
# mirrorlog core (corelog)
# resizeable (resizable)
# allocatable (allocation)
# resizeable (allocation)
# activate (available)
# rebuild (raidrebuild)
# syncaction (raidsyncaction)
# writemostly (raidwritemostly)
# minrecoveryrate (raidminrecoveryrate)
# maxrecoveryrate (raidmaxrecoveryrate)
# writebehind (raidwritebehind)
#
#
# For efficiency, sets of options can be defined and reused
# in multiple command definitions.
#
# To define a common set of options:
# OO_NAME: --foo, --bar String
#
@@ -84,6 +114,19 @@ OO_ALL: --commandprofile String, --config String, --debug,
--driverloaded Bool, --help, --profile String, --quiet,
--verbose, --version, --yes
#
# These common options are displayed once at the end of
# a given command's usage. This is done to avoid excessive
# repetition of common options, which may obscure the more
# interesting and relevant parts of a common prototype.
# This definition is *only* used when generating the command
# usage strings, and is the basis for the division between
# the "usage" and "usage_common" strings. This OO defn does
# not relate to which optional opts are accepted by commands,
# which is defined by the OO line.
#
OO_USAGE_COMMON: OO_ALL, --force, --test, --noudevsync
#
# pvs, lvs, vgs, fullreport
#
@@ -92,12 +135,12 @@ OO_REPORT: --aligned, --all, --binary, --configreport String, --foreign,
--nameprefixes, --noheadings, --nolocking, --nosuffix,
--options String, --partial, --readonly, --reportformat String, --rows,
--select String, --separator String, --shared, --sort String,
--trustcache, --unbuffered, --units String, --unquoted
--trustcache, --unbuffered, --units Units, --unquoted
#
# config, dumpconfig, lvmconfig
#
OO_CONFIG: --atversion String, --configtype String, --file String, --ignoreadvanced,
OO_CONFIG: --atversion String, --typeconfig String, --file String, --ignoreadvanced,
--ignoreunsupported, --ignorelocal, --list, --mergedconfig, --metadataprofile String,
--sinceversion String, --showdeprecated, --showunsupported, --validate, --withsummary,
--withcomments, --withspaces, --unconfigured, --withversions
@@ -141,12 +184,12 @@ OO_LVCHANGE: --autobackup Bool, --force, --ignorelockingfailure,
# because it can function as a required opt.
#
OO_LVCHANGE_META: --addtag Tag, --deltag Tag,
--alloc String, --contiguous Bool,
--alloc Alloc, --contiguous Bool,
--detachprofile, --metadataprofile String, --profile String,
--permission, --readahead Number|String, --setactivationskip Bool,
--errorwhenfull Bool, --discards String, --zero Bool,
--cachemode String, --cachepolicy String, --cachesettings String,
--minrecoveryrate Number, --maxrecoveryrate Number,
--permission Permission, --readahead Readahead, --setactivationskip Bool,
--errorwhenfull Bool, --discards Discards, --zero Bool,
--cachemode CacheMode, --cachepolicy String, --cachesettings String,
--minrecoveryrate SizeKB, --maxrecoveryrate SizeKB,
--writebehind Number, --writemostly PV
lvchange OO_LVCHANGE_META VG|LV|Tag|Select ...
@@ -161,8 +204,8 @@ OO: OO_LVCHANGE_META, OO_LVCHANGE
lvchange --rebuild PV VG|LV|Tag|Select ...
OO: OO_LVCHANGE_META, OO_LVCHANGE
lvchange --activate String VG|LV|Tag|Select ...
OO: --activationmode String, --partial, --ignoreactivationskip, OO_LVCHANGE_META, OO_LVCHANGE
lvchange --activate Active VG|LV|Tag|Select ...
OO: --activationmode ActivationMode, --partial, --ignoreactivationskip, OO_LVCHANGE_META, OO_LVCHANGE
lvchange --refresh VG|LV|Tag|Select ...
OO: OO_LVCHANGE_META, OO_LVCHANGE
@@ -177,82 +220,83 @@ lvchange --persistent Bool VG|LV|Tag|Select ...
OO: --minor Number, --major Number, OO_LVCHANGE_META, OO_LVCHANGE
OO_LVCONVERT_RAID: --mirrors Number, --stripes_long Number,
--stripesize Number, --regionsize Number
OO_LVCONVERT_RAID: --mirrors SNumber, --stripes_long Number,
--stripesize SizeKB, --regionsize SizeMB
OO_LVCONVERT_POOL: --poolmetadata LV, --poolmetadatasize Number,
--poolmetadataspare Bool, --readahead Number|String, --chunksize Number
OO_LVCONVERT_POOL: --poolmetadata LV, --poolmetadatasize SizeMB,
--poolmetadataspare Bool, --readahead Readahead, --chunksize SizeKB
OO_LVCONVERT: --alloc String, --background, --force, --noudevsync,
OO_LVCONVERT: --alloc Alloc, --background, --force, --noudevsync,
--test, --usepolicies
# FIXME: use different option names for different operations
lvconvert --merge LV_linear|LV_striped|LV_raid|LV_thin|LV_snapshot|VG|Tag ...
lvconvert --merge LV_linear_striped_raid_thin_snapshot|VG|Tag ...
OO: --background, --interval Number
DESC: Merge LV that was previously split from a mirror.
DESC: Merge thin LV into its origin LV.
DESC: Merge COW snapshot LV into its origin.
lvconvert --type snapshot LV_linear|LV_striped|LV_raid LV_snapshot
OO: --chunksize Number, --zero Bool, OO_LVCONVERT
lvconvert --type snapshot LV_linear_striped_raid LV_snapshot
OO: --chunksize SizeKB, --zero Bool, OO_LVCONVERT
DESC: Combine LV with a previously split snapshot LV.
lvconvert --type thin --thinpool LV LV_linear|LV_striped|LV_raid
lvconvert --type thin --thinpool LV LV_linear_striped_raid
OO: --originname LV_new, OO_LVCONVERT_POOL, OO_LVCONVERT
DESC: Convert LV to type thin with an external origin.
# alternate form of lvconvert --type thin
lvconvert --thin --thinpool LV LV_linear|LV_striped|LV_raid
lvconvert --thin --thinpool LV LV_linear_striped_raid
OO: --type thin, --originname LV_new, OO_LVCONVERT_POOL, OO_LVCONVERT
DESC: Convert LV to type thin with an external origin (infers --type thin).
lvconvert --type cache --cachepool LV LV_linear|LV_striped|LV_raid|LV_thinpool
lvconvert --type cache --cachepool LV LV_linear_striped_raid_thinpool
OO: --cachepolicy String, --cachesettings String, OO_LVCONVERT_POOL, OO_LVCONVERT
DESC: Convert LV to type cache.
# alternate form of lvconvert --type cache
lvconvert --cache --cachepool LV LV_linear|LV_striped|LV_raid|LV_thinpool
lvconvert --cache --cachepool LV LV_linear_striped_raid_thinpool
OO: --type cache, --cachepolicy String, --cachesettings String, OO_LVCONVERT_POOL, OO_LVCONVERT
DESC: Convert LV to type cache (infers --type cache).
lvconvert --type thin-pool LV_linear|LV_striped|LV_raid|LV_cache
OO: --discards String, --zero Bool, OO_LVCONVERT_POOL, OO_LVCONVERT
lvconvert --type thin-pool LV_linear_striped_raid_cache
OO: --discards Discards, --zero Bool, OO_LVCONVERT_POOL, OO_LVCONVERT
DESC: Convert LV to type thin-pool.
lvconvert --type cache-pool LV_linear|LV_striped|LV_raid
lvconvert --type cache-pool LV_linear_striped_raid
OO: OO_LVCONVERT_POOL, OO_LVCONVERT
DESC: Convert LV to type cache-pool.
lvconvert --type mirror LV_linear|LV_striped|LV_raid
lvconvert --type mirror LV_linear_striped_raid
OO: OO_LVCONVERT_RAID, OO_LVCONVERT
OP: PV ...
DESC: Convert LV to type mirror.
lvconvert --type raid LV_linear|LV_striped|LV_mirror|LV_raid
lvconvert --type raid LV_linear_striped_mirror_raid
OO: OO_LVCONVERT_RAID, OO_LVCONVERT
OP: PV ...
DESC: Convert LV to type raid.
DESC: Change LV raid type.
lvconvert --mirrors Number LV_raid|LV_mirror
lvconvert --mirrors SNumber LV_raid_mirror
OO: OO_LVCONVERT
OP: PV ...
DESC: Change the number of mirror images in the LV.
lvconvert --mirrors Number LV_linear|LV_striped
lvconvert --mirrors SNumber LV_linear_striped
OO: OO_LVCONVERT_RAID, OO_LVCONVERT
OP: PV ...
DESC: Alternate form to convert LV to type raid1 or mirror (use --type raid1|mirror).
DESC: Alternate form to convert LV to type raid1 or mirror
DESC: (use --type raid1|mirror).
lvconvert --splitmirrors Number --name LV_new LV_raid|LV_mirror|LV_cache
lvconvert --splitmirrors Number --name LV_new LV_raid1_mirror_cache
OO: OO_LVCONVERT
DESC: Split images from a raid1 or mirror LV and use them to create a new LV.
lvconvert --splitmirrors Number --trackchanges LV_raid|LV_cache
lvconvert --splitmirrors Number --trackchanges LV_raid1_cache
OO: OO_LVCONVERT
DESC: Split images from a raid1 LV and use them to create a new LV.
lvconvert --repair LV_raid|LV_mirror|LV_thinpool
lvconvert --repair LV_raid_mirror_thinpool
OO: OO_LVCONVERT
DESC: Replace failed PVs in a mirror or raid LV.
DESC: Repair a thin pool.
@@ -267,19 +311,19 @@ OO: OO_LVCONVERT_RAID, OO_LVCONVERT
OP: PV ...
DESC: Convert LV to type striped.
lvconvert --type linear LV_raid|LV_mirror
lvconvert --type linear LV_raid_mirror
OO: OO_LVCONVERT
DESC: Convert LV to type linear.
lvconvert --mirrorlog String LV_mirror
lvconvert --mirrorlog MirrorLog LV_mirror
OO: OO_LVCONVERT
DESC: Change the type of log used by LV.
lvconvert --splitcache LV_cachepool|LV_cache|LV_thinpool
lvconvert --splitcache LV_cachepool_cache_thinpool
OO: OO_LVCONVERT
DESC: Separate and preserve a cache pool from a cache LV.
lvconvert --uncache LV_cache|LV_thinpool
lvconvert --uncache LV_cache_thinpool
OO: OO_LVCONVERT
DESC: Separate and remove a cache pool from a cache LV.
@@ -303,77 +347,77 @@ lvconvert LV_mirror
DESC: Poll LV to collapse resync layers.
# FIXME: add a new option defining this operation, e.g. --swapmetadata
lvconvert --poolmetadata LV LV_thinpool|LV_cachepool
lvconvert --poolmetadata LV LV_thinpool_cachepool
DESC: Swap metadata LV in a thin pool or cache pool (temporary command).
# --extents or --size are interchangable
OO_LVCREATE: --addtag Tag, --alloc String, --autobackup Bool, --activate String,
OO_LVCREATE: --addtag Tag, --alloc Alloc, --autobackup Bool, --activate Active,
--contiguous Bool, --ignoreactivationskip, --ignoremonitoring, --major Number,
--metadataprofile String, --minor Number, --monitor Bool, --name String, --nosync,
--noudevsync, --permission, --persistent Bool, --readahead Number|String,
--noudevsync, --permission Permission, --persistent Bool, --readahead Readahead,
--reportformat String, --setactivationskip Bool, --test, --wipesignatures Bool,
--zero Bool
OO_LVCREATE_CACHE: --cachemode String, --cachepolicy String, --cachesettings String
OO_LVCREATE_CACHE: --cachemode CacheMode, --cachepolicy String, --cachesettings String
OO_LVCREATE_POOL: --poolmetadatasize Number, --poolmetadataspare Bool, --chunksize Number
OO_LVCREATE_POOL: --poolmetadatasize SizeMB, --poolmetadataspare Bool, --chunksize SizeKB
OO_LVCREATE_THIN: --discards String, --errorwhenfull Bool
OO_LVCREATE_THIN: --discards Discards, --errorwhenfull Bool
OO_LVCREATE_RAID: --mirrors Number, --stripes Number, --stripesize Number,
--regionsize Number, --minrecoveryrate Number, --maxrecoveryrate Number
OO_LVCREATE_RAID: --mirrors SNumber, --stripes Number, --stripesize SizeKB,
--regionsize SizeMB, --minrecoveryrate SizeKB, --maxrecoveryrate SizeKB
lvcreate --type error --size Number VG
lvcreate --type error --size SizeMB VG
OO: OO_LVCREATE
DESC: Create an LV that returns errors when used.
lvcreate --type zero --size Number VG
lvcreate --type zero --size SizeMB VG
OO: OO_LVCREATE
DESC: Create an LV that returns zeros when read.
lvcreate --type linear --size Number VG
lvcreate --type linear --size SizeMB VG
OO: OO_LVCREATE
OP: PV ...
DESC: Create a linear LV.
lvcreate --type striped --size Number VG
OO: --stripes Number, --stripesize Number, OO_LVCREATE
lvcreate --type striped --size SizeMB VG
OO: --stripes Number, --stripesize SizeKB, OO_LVCREATE
OP: PV ...
DESC: Create a striped LV.
lvcreate --type mirror --size Number VG
OO: --mirrors Number, --mirrorlog String, --corelog, --regionsize Number, OO_LVCREATE
lvcreate --type mirror --size SizeMB VG
OO: --mirrors SNumber, --mirrorlog MirrorLog, --corelog, --regionsize SizeMB, OO_LVCREATE
OP: PV ...
DESC: Create a mirror LV.
lvcreate --type raid --size Number VG
lvcreate --type raid --size SizeMB VG
OO: OO_LVCREATE_RAID, OO_LVCREATE
OP: PV ...
DESC: Create a raid LV (a specific raid level must be used, e.g. raid1).
DESC: Create a raid LV (a specific raid level must be used, e.g. raid1.
lvcreate --type snapshot --size Number LV
lvcreate --type snapshot --size SizeMB LV
OO: OO_LVCREATE
OP: PV ...
DESC: Create a COW snapshot from an origin LV.
lvcreate --type snapshot --size Number --virtualsize Number VG
OO: --virtualoriginsize Number, OO_LVCREATE
lvcreate --type snapshot --size SizeMB --virtualsize SizeMB VG
OO: --virtualoriginsize SizeMB, OO_LVCREATE
OP: PV ...
DESC: Create a sparse COW snapshot LV of a virtual origin LV.
lvcreate --type thin-pool --size Number VG
lvcreate --type thin-pool --size SizeMB VG
OO: OO_LVCREATE_POOL, OO_LVCREATE_THIN, OO_LVCREATE
OP: PV ...
DESC: Create a thin pool.
lvcreate --type cache-pool --size Number VG
lvcreate --type cache-pool --size SizeMB VG
OO: OO_LVCREATE_POOL, OO_LVCREATE_CACHE, OO_LVCREATE
OP: PV ...
DESC: Create a cache pool.
lvcreate --type thin --virtualsize Number --thinpool LV_thinpool
lvcreate --type thin --virtualsize SizeMB --thinpool LV_thinpool
OO: OO_LVCREATE_POOL, OO_LVCREATE_THIN, OO_LVCREATE
DESC: Create a thin LV in a thin pool.
@@ -383,98 +427,109 @@ DESC: Create a thin LV that is a snapshot of an existing thin LV.
lvcreate --type thin --snapshot --thinpool LV_thinpool LV
OO: OO_LVCREATE_POOL, OO_LVCREATE_THIN, OO_LVCREATE
DESC: Create a thin LV that is a snapshot of an external origin LV named in arg pos 1.
DESC: Create a thin LV that is a snapshot of an external origin LV
DESC: named in arg pos 1.
lvcreate --type thin --virtualsize Number --size Number --thinpool LV_new
lvcreate --type thin --virtualsize SizeMB --size SizeMB --thinpool LV_new
OO: OO_LVCREATE_POOL, OO_LVCREATE_THIN, OO_LVCREATE
OP: PV ...
DESC: Create a thin LV, first creating a thin pool for it, where the new thin pool is named by the --thinpool arg.
DESC: Create a thin LV, first creating a thin pool for it,
DESC: where the new thin pool is named by the --thinpool arg.
lvcreate --type thin --virtualsize Number --size Number LV_new
lvcreate --type thin --virtualsize SizeMB --size SizeMB LV_new
OO: OO_LVCREATE_POOL, OO_LVCREATE_THIN, OO_LVCREATE
OP: PV ...
DESC: Create a thin LV, first creating a thin pool for it, where the new thin pool is named in arg pos 1.
DESC: Create a thin LV, first creating a thin pool for it,
DESC: where the new thin pool is named in arg pos 1.
lvcreate --type thin --virtualsize Number --size Number VG
lvcreate --type thin --virtualsize SizeMB --size SizeMB VG
OO: OO_LVCREATE_POOL, OO_LVCREATE_THIN, OO_LVCREATE
OP: PV ...
DESC: Create a thin LV, first creating a thin pool for it.
# FIXME: this should be done by lvconvert, and this command deprecated
lvcreate --type cache --size Number LV
lvcreate --type cache --size SizeMB LV
OO: OO_LVCREATE_POOL, OO_LVCREATE_CACHE, OO_LVCREATE
OP: PV ...
DESC: Convert the specified LV to type cache after creating a new cache pool LV to use.
DESC: Convert the specified LV to type cache after creating a new
DESC: cache pool LV to use.
lvcreate --type cache --size Number --cachepool LV_cachepool
lvcreate --type cache --size SizeMB --cachepool LV_cachepool
OO: OO_LVCREATE_POOL, OO_LVCREATE_CACHE, OO_LVCREATE
OP: PV ...
DESC: Create a cache LV, first creating a new origin LV, then combining it with the existing cache pool in arg pos 1.
DESC: Create a cache LV, first creating a new origin LV,
DESC: then combining it with the existing cache pool in arg pos 1.
lvcreate --size Number VG
lvcreate --size SizeMB VG
OO: --type linear, OO_LVCREATE
OP: PV ...
DESC: Create a linear LV. (default --type linear)
DESC: Create a linear LV, --name is usually specified (default --type linear).
lvcreate --stripes Number --size Number VG
OO: --type striped, --stripesize Number, OO_LVCREATE
lvcreate --stripes Number --size SizeMB VG
OO: --type striped, --stripesize SizeKB, OO_LVCREATE
OP: PV ...
DESC: Create a striped LV. (infers --type striped)
DESC: Create a striped LV (infers --type striped).
lvcreate --mirrors Number --size Number VG
OO: --type raid1|mirror, --mirrorlog String, --corelog, OO_LVCREATE_RAID, OO_LVCREATE
lvcreate --mirrors SNumber --size SizeMB VG
OO: --type raid1, --type mirror, --mirrorlog MirrorLog, --corelog, OO_LVCREATE_RAID, OO_LVCREATE
OP: PV ...
DESC: Create a raid1 or mirror LV. (infers --type raid1|mirror)
DESC: Create a raid1 or mirror LV (infers --type raid1|mirror).
lvcreate --snapshot --size Number LV
lvcreate --snapshot --size SizeMB LV
OO: --type snapshot, OO_LVCREATE
OP: PV ...
DESC: Create a COW snapshot LV of the origin LV in arg pos 1. (infers --type snapshot)
DESC: Create a COW snapshot LV of the origin LV in arg pos 1
DESC: (infers --type snapshot).
lvcreate --thin --size Number VG
lvcreate --thin --size SizeMB VG
OO: --type thin-pool, OO_LVCREATE_POOL, OO_LVCREATE_THIN, OO_LVCREATE
OP: PV ...
DESC: Create a thin pool. (infers --type thin-pool)
DESC: Create a thin pool (infers --type thin-pool).
lvcreate --cache --size Number VG
lvcreate --cache --size SizeMB VG
OO: --type cache-pool, OO_LVCREATE_POOL, OO_LVCREATE_CACHE, OO_LVCREATE
OP: PV ...
DESC: Create a cache pool. (infers --type cache-pool)
DESC: Create a cache pool (infers --type cache-pool).
lvcreate --snapshot LV_thin
OO: --type thin, OO_LVCREATE_THIN, OO_LVCREATE
DESC: Create a thin LV that is a snapshot of an existing thin LV. (infers --type thin)
DESC: Create a thin LV that is a snapshot of an existing thin LV
DESC: (infers --type thin).
lvcreate --snapshot --thinpool LV_thinpool LV
OO: --type thin, OO_LVCREATE_THIN, OO_LVCREATE
DESC: Create a thin LV that is a snapshot of an external origin LV. (infers --type thin)
DESC: Create a thin LV that is a snapshot of an external origin LV
DESC: (infers --type thin).
lvcreate --virtualsize Number --thinpool LV_thinpool
lvcreate --virtualsize SizeMB --thinpool LV_thinpool
OO: --type thin, OO_LVCREATE_THIN, OO_LVCREATE
DESC: Create a thin LV in a thin pool. (infers --type thin)
DESC: Create a thin LV in a thin pool (infers --type thin).
lvcreate --size Number --cachepool LV_cachepool
lvcreate --size SizeMB --cachepool LV_cachepool
OO: --type cache, OO_LVCREATE_CACHE, OO_LVCREATE
OP: PV ...
DESC: Create a new origin LV, combining it with an existing cache pool to create a new cache LV. (infers --type cache)
DESC: Create a new origin LV, combining it with an existing
DESC: cache pool to create a new cache LV (infers --type cache).
lvcreate --thin --virtualsize Number --size Number --thinpool LV_new
lvcreate --thin --virtualsize SizeMB --size SizeMB --thinpool LV_new
OO: --type thin, OO_LVCREATE_POOL, OO_LVCREATE_THIN, OO_LVCREATE
OP: PV ...
DESC: Create a thin LV, first creating a thin pool for it, where the new thin pool is named by the --thinpool arg. (infers --type thin)
DESC: Create a thin LV, first creating a thin pool for it, where the new
DESC: thin pool is named by the --thinpool arg (infers --type thin).
lvcreate --thin --virtualsize Number --size Number LV_new
lvcreate --thin --virtualsize SizeMB --size SizeMB LV_new
OO: --type thin, OO_LVCREATE_POOL, OO_LVCREATE_THIN, OO_LVCREATE
OP: PV ...
DESC: Create a thin LV, first creating a thin pool for it, where the new thin pool is named in arg pos 1. (infers --type thin)
DESC: Create a thin LV, first creating a thin pool for it, where the new
DESC: thin pool is named in arg pos 1 (infers --type thin).
lvcreate --size Number --virtualsize Number VG
lvcreate --size SizeMB --virtualsize SizeMB VG
OO: --type thin, --type snapshot, --thin, --snapshot,
--virtualoriginsize Number, OO_LVCREATE_POOL, OO_LVCREATE_THIN, OO_LVCREATE
--virtualoriginsize SizeMB, OO_LVCREATE_POOL, OO_LVCREATE_THIN, OO_LVCREATE
OP: PV ...
DESC: Create a thin LV, first creating a thin pool for it. (infers --type thin)
DESC: Create a sparse snapshot of a virtual origin LV. (infers --type snapshot)
DESC: (infers --type thin or --type snapshot according to sparse_segtype_default)
DESC: Create a thin LV, first creating a thin pool for it (infers --type thin).
DESC: Create a sparse snapshot of a virtual origin LV (infers --type snapshot).
DESC: Infers --type thin or --type snapshot according to sparse_segtype_default.
lvdisplay
OO: --aligned, --all, --binary, --colon, --columns,
@@ -482,31 +537,31 @@ OO: --aligned, --all, --binary, --colon, --columns,
--ignoreskippedcluster, --logonly, --maps, --noheadings,
--nosuffix, --options String, --sort String, --partial, --readonly,
--reportformat String, --segments, --select String, --separator String,
--shared, --unbuffered, --units String
--shared, --unbuffered, --units Units
OP: VG|LV|Tag ...
# --extents or --size are interchangable
lvextend --size Number LV
OO: --alloc String, --autobackup Bool, --force, --mirrors Number,
lvextend --size SizeMB LV
OO: --alloc Alloc, --autobackup Bool, --force, --mirrors SNumber,
--nofsck, --nosync, --noudevsync, --reportformat String, --resizefs,
--stripes Number, --stripesize Number, --test, --poolmetadatasize Number
--stripes Number, --stripesize SizeKB, --test, --poolmetadatasize SizeMB
OP: PV ...
lvextend LV PV ...
OO: --alloc String, --autobackup Bool, --force, --mirrors Number,
OO: --alloc Alloc, --autobackup Bool, --force, --mirrors SNumber,
--nofsck, --nosync, --noudevsync,
--reportformat String, --resizefs, --stripes Number, --stripesize Number,
--reportformat String, --resizefs, --stripes Number, --stripesize SizeKB,
--test
lvextend --poolmetadatasize Number LV_thinpool
OO: --alloc String, --autobackup Bool, --force, --mirrors Number,
lvextend --poolmetadatasize SizeMB LV_thinpool
OO: --alloc Alloc, --autobackup Bool, --force, --mirrors SNumber,
--nofsck, --nosync, --noudevsync,
--reportformat String, --stripes Number, --stripesize Number,
--reportformat String, --stripes Number, --stripesize SizeKB,
--test
OP: PV ...
lvextend --usepolicies LV_thinpool|LV_snapshot
OO: --alloc String, --autobackup Bool, --force, --mirrors Number,
lvextend --usepolicies LV_thinpool_snapshot
OO: --alloc Alloc, --autobackup Bool, --force, --mirrors SNumber,
--nofsck, --nosync, --noudevsync,
--reportformat String, --resizefs,
--test
@@ -525,7 +580,7 @@ lvmsar
OO: --full, --stdin
# --extents or --size are interchangable
lvreduce --size Number LV
lvreduce --size SizeMB LV
OO: --autobackup Bool, --force, --nofsck, --noudevsync,
--reportformat String, --resizefs, --test
@@ -540,22 +595,22 @@ lvrename LV LV_new
OO: --autobackup Bool, --noudevsync, --reportformat String, --test
# --extents or --size are interchangable
lvresize --size Number LV
OO: --alloc String, --autobackup Bool, --force,
lvresize --size SizeMB LV
OO: --alloc Alloc, --autobackup Bool, --force,
--nofsck, --nosync, --noudevsync, --reportformat String, --resizefs,
--stripes Number, --stripesize Number, --test, --poolmetadatasize Number
--stripes Number, --stripesize SizeKB, --test, --poolmetadatasize SizeMB
OP: PV ...
lvresize LV PV ...
OO: --alloc String, --autobackup Bool, --force,
OO: --alloc Alloc, --autobackup Bool, --force,
--nofsck, --nosync, --noudevsync,
--reportformat String, --resizefs, --stripes Number, --stripesize Number,
--reportformat String, --resizefs, --stripes Number, --stripesize SizeKB,
--test
lvresize --poolmetadatasize Number LV_thinpool
OO: --alloc String, --autobackup Bool, --force,
lvresize --poolmetadatasize SizeMB LV_thinpool
OO: --alloc Alloc, --autobackup Bool, --force,
--nofsck, --nosync, --noudevsync,
--reportformat String, --stripes Number, --stripesize Number,
--reportformat String, --stripes Number, --stripesize SizeKB,
--test
OP: PV ...
@@ -587,7 +642,7 @@ pvchange OO_PVCHANGE_META PV|Select ...
OO: --select String, OO_PVCHANGE
pvresize PV ...
OO: --setphysicalvolumesize Number, --reportformat String, --test
OO: --setphysicalvolumesize SizeMB, --reportformat String, --test
pvck PV ...
OO: --labelsector Number
@@ -597,10 +652,10 @@ OO: --labelsector Number
# which is actually --uuid string on the command line.
#
pvcreate PV ...
OO: --dataalignment Number, --dataalignmentoffset Number, --bootloaderareasize Number,
--force, --test, --labelsector Number, --metadatatype String,
--pvmetadatacopies Number, --metadatasize Number, --metadataignore Bool,
--norestorefile, --setphysicalvolumesize Number,
OO: --dataalignment SizeKB, --dataalignmentoffset SizeKB, --bootloaderareasize SizeMB,
--force, --test, --labelsector Number, --metadatatype MetadataType,
--pvmetadatacopies Number, --metadatasize SizeMB, --metadataignore Bool,
--norestorefile, --setphysicalvolumesize SizeMB,
--reportformat String, --restorefile String, --uuidstr String, --zero Bool
pvdata
@@ -610,11 +665,11 @@ OO: --aligned, --all, --binary, --colon, --columns, --configreport String,
--foreign, --ignorelockingfailure, --ignoreskippedcluster,
--logonly, --maps, --noheadings, --nosuffix, --options String,
--readonly, --reportformat String, --select String, --separator String, --shared,
--short, --sort String, --unbuffered, --units String
--short, --sort String, --unbuffered, --units Units
OP: PV|Tag ...
pvmove PV
OO: --abort, --alloc String, --atomic, --autobackup Bool, --background,
OO: --abort, --alloc Alloc, --atomic, --autobackup Bool, --background,
--interval Number, --name LV, --noudevsync, --reportformat String, --test
OP: PV ...
@@ -635,9 +690,9 @@ pvscan
OO: --ignorelockingfailure, --reportformat String, --exported, --novolumegroup,
--short, --uuid
pvscan --cache
pvscan --cache_long
OO: --ignorelockingfailure, --reportformat String, --background,
--activate String, --major Number, --minor Number,
--activate Active, --major Number, --minor Number,
OP: PV|String ...
segtypes
@@ -651,7 +706,7 @@ OO: --file String, --foreign, --ignorelockingfailure, --partial, --readonly,
--reportformat String
vgcfgrestore VG
OO: --file String, --force_long, --list, --metadatatype String, --test
OO: --file String, --force_long, --list, --metadatatype MetadataType, --test
vgcfgrestore --list --file String
@@ -667,9 +722,9 @@ OO_VGCHANGE: --autobackup Bool, --ignoremonitoring, --ignoreskippedcluster,
# because it can function as a required opt.
#
OO_VGCHANGE_META: --addtag Tag, --deltag Tag,
--logicalvolume Number, --maxphysicalvolumes Number, --alloc String, --uuid,
--clustered Bool, --metadatacopies Number, --vgmetadatacopies Number|String,
--physicalextentsize Number, --resizeable Bool, --systemid String, --locktype String,
--logicalvolume Number, --maxphysicalvolumes Number, --alloc Alloc, --uuid,
--clustered Bool, --metadatacopies MetadataCopies, --vgmetadatacopies MetadataCopies,
--physicalextentsize SizeMB, --resizeable Bool, --systemid String, --locktype LockType,
--profile String, --detachprofile, --metadataprofile String,
vgchange OO_VGCHANGE_META
@@ -684,8 +739,8 @@ vgchange --poll Bool
OO: --ignorelockingfailure, OO_VGCHANGE_META, OO_VGCHANGE
OP: VG|Tag ...
vgchange --activate String
OO: --activationmode String, --ignoreactivationskip, --partial, --sysinit,
vgchange --activate Active
OO: --activationmode ActivationMode, --ignoreactivationskip, --partial, --sysinit,
--ignorelockingfailure, --monitor Bool, --poll Bool, OO_VGCHANGE_META, OO_VGCHANGE
OP: VG|Tag ...
@@ -706,24 +761,24 @@ OO: --reportformat String
OP: VG|Tag ...
vgconvert VG ...
OO: --force, --test, --labelsector Number, --bootloaderareasize Number,
--metadatatype String, --pvmetadatacopies Number,
--metadatasize Number, --reportformat String
OO: --force, --test, --labelsector Number, --bootloaderareasize SizeMB,
--metadatatype MetadataType, --pvmetadatacopies Number,
--metadatasize SizeMB, --reportformat String
vgcreate VG_new PV ...
OO: --addtag Tag, --alloc String, --autobackup Bool, --clustered Bool, --maxlogicalvolumes Number,
--maxphysicalvolumes Number, --metadataprofile String, --metadatatype String,
--physicalextentsize Number, --test, --force, --zero Bool, --labelsector Number,
--metadatasize Number, --pvmetadatacopies Number, --reportformat String, --metadatacopies Number,
--vgmetadatacopies Number|String, --dataalignment Number, --dataalignmentoffset Number,
--shared, --systemid String, --locktype String, --lockopt String
OO: --addtag Tag, --alloc Alloc, --autobackup Bool, --clustered Bool, --maxlogicalvolumes Number,
--maxphysicalvolumes Number, --metadataprofile String, --metadatatype MetadataType,
--physicalextentsize SizeMB, --test, --force, --zero Bool, --labelsector Number,
--metadatasize SizeMB, --pvmetadatacopies Number, --reportformat String, --metadatacopies MetadataCopies,
--vgmetadatacopies MetadataCopies, --dataalignment SizeKB, --dataalignmentoffset SizeKB,
--shared, --systemid String, --locktype LockType, --lockopt String
vgdisplay
OO: --activevolumegroups, --aligned, --binary, --colon, --columns,
--configreport String, --foreign, --ignorelockingfailure,
--ignoreskippedcluster, --logonly, --noheadings, --nosuffix,
--options String, --partial, --readonly, --reportformat String, --select String,
--shared, --short, --separator String, --sort String, --unbuffered, --units String
--shared, --short, --separator String, --sort String, --unbuffered, --units Units
OP: VG|Tag ...
OO_VGEXPORT: --reportformat String, --test
@@ -736,9 +791,9 @@ OO: OO_VGEXPORT
vgextend VG PV ...
OO: --autobackup Bool, --test,
--force, --zero Bool, --labelsector Number, --metadatatype String,
--metadatasize Number, --pvmetadatacopies Number,
--metadataignore Bool, --dataalignment Number, --dataalignmentoffset Number,
--force, --zero Bool, --labelsector Number, --metadatatype MetadataType,
--metadatasize SizeMB, --pvmetadatacopies Number,
--metadataignore Bool, --dataalignment SizeKB, --dataalignmentoffset SizeKB,
--reportformat String, --restoremissing
OO_VGIMPORT: --force, --reportformat String, --test
@@ -789,9 +844,9 @@ OO: --cache_long, --ignorelockingfailure, --mknodes, --notifydbus,
OO_VGSPLIT: --autobackup Bool, --test
OO_VGSPLIT_NEW: --alloc String, --clustered Bool,
OO_VGSPLIT_NEW: --alloc Alloc, --clustered Bool,
--maxlogicalvolumes Number, --maxphysicalvolumes Number,
--metadatatype String, --vgmetadatacopies Number|String
--metadatatype MetadataType, --vgmetadatacopies MetadataCopies
vgsplit VG VG PV ...
OO: OO_VGSPLIT

File diff suppressed because it is too large Load Diff

View File

@@ -17,215 +17,214 @@
* Put all long args that don't have a corresponding short option first.
*/
/* *INDENT-OFF* */
arg(abort_ARG, '\0', "abort", NULL, 0, 0)
arg(activationmode_ARG, '\0', "activationmode", string_arg, 0, 0)
arg(addtag_ARG, '\0', "addtag", tag_arg, ARG_GROUPABLE, 0)
arg(aligned_ARG, '\0', "aligned", NULL, 0, 0)
arg(alloc_ARG, '\0', "alloc", alloc_arg, 0, 0)
arg(atomic_ARG, '\0', "atomic", NULL, 0, 0)
arg(atversion_ARG, '\0', "atversion", string_arg, 0, 0)
arg(binary_ARG, '\0', "binary", NULL, 0, 0)
arg(bootloaderareasize_ARG, '\0', "bootloaderareasize", size_mb_arg, 0, 0)
arg(cache_long_ARG, '\0', "cache", NULL, 0, 0)
arg(cachemode_ARG, '\0', "cachemode", cachemode_arg, 0, 0)
arg(cachepool_ARG, '\0', "cachepool", string_arg, 0, 0)
arg(commandprofile_ARG, '\0', "commandprofile", string_arg, 0, 0)
arg(config_ARG, '\0', "config", string_arg, 0, 0)
arg(configreport_ARG, '\0', "configreport", string_arg, ARG_GROUPABLE, 1)
arg(configtype_ARG, '\0', "configtype", string_arg, 0, 0)
arg(corelog_ARG, '\0', "corelog", NULL, 0, 0)
arg(dataalignment_ARG, '\0', "dataalignment", size_kb_arg, 0, 0)
arg(dataalignmentoffset_ARG, '\0', "dataalignmentoffset", size_kb_arg, 0, 0)
arg(deltag_ARG, '\0', "deltag", tag_arg, ARG_GROUPABLE, 0)
arg(detachprofile_ARG, '\0', "detachprofile", NULL, 0, 0)
arg(discards_ARG, '\0', "discards", discards_arg, 0, 0)
arg(driverloaded_ARG, '\0', "driverloaded", yes_no_arg, 0, 0)
arg(errorwhenfull_ARG, '\0', "errorwhenfull", yes_no_arg, 0, 0)
arg(force_long_ARG, '\0', "force", NULL, ARG_COUNTABLE, 0)
arg(foreign_ARG, '\0', "foreign", NULL, 0, 0)
arg(handlemissingpvs_ARG, '\0', "handlemissingpvs", NULL, 0, 0)
arg(ignoreadvanced_ARG, '\0', "ignoreadvanced", NULL, 0, 0)
arg(ignorelocal_ARG, '\0', "ignorelocal", NULL, 0, 0)
arg(ignorelockingfailure_ARG, '\0', "ignorelockingfailure", NULL, 0, 0)
arg(ignoremonitoring_ARG, '\0', "ignoremonitoring", NULL, 0, 0)
arg(ignoreskippedcluster_ARG, '\0', "ignoreskippedcluster", NULL, 0, 0)
arg(ignoreunsupported_ARG, '\0', "ignoreunsupported", NULL, 0, 0)
arg(labelsector_ARG, '\0', "labelsector", int_arg, 0, 0)
arg(lockopt_ARG, '\0', "lockopt", string_arg, 0, 0)
arg(lockstart_ARG, '\0', "lockstart", NULL, 0, 0)
arg(lockstop_ARG, '\0', "lockstop", NULL, 0, 0)
arg(locktype_ARG, '\0', "locktype", locktype_arg, 0, 0)
arg(logonly_ARG, '\0', "logonly", NULL, 0, 0)
arg(maxrecoveryrate_ARG, '\0', "maxrecoveryrate", size_kb_arg, 0, 0)
arg(merge_ARG, '\0', "merge", NULL, 0, 0)
arg(mergedconfig_ARG, '\0', "mergedconfig", NULL, 0, 0)
arg(metadatacopies_ARG, '\0', "metadatacopies", metadatacopies_arg, 0, 0)
arg(metadataignore_ARG, '\0', "metadataignore", yes_no_arg, 0, 0)
arg(metadataprofile_ARG, '\0', "metadataprofile", string_arg, 0, 0)
arg(metadatasize_ARG, '\0', "metadatasize", size_mb_arg, 0, 0)
arg(minor_ARG, '\0', "minor", int_arg, ARG_GROUPABLE, 0)
arg(minrecoveryrate_ARG, '\0', "minrecoveryrate", size_kb_arg, 0, 0)
arg(mirrorlog_ARG, '\0', "mirrorlog", mirrorlog_arg, 0, 0)
arg(mirrorsonly_ARG, '\0', "mirrorsonly", NULL, 0, 0)
arg(mknodes_ARG, '\0', "mknodes", NULL, 0, 0)
arg(monitor_ARG, '\0', "monitor", yes_no_arg, 0, 0)
arg(nameprefixes_ARG, '\0', "nameprefixes", NULL, 0, 0)
arg(noheadings_ARG, '\0', "noheadings", NULL, 0, 0)
arg(nohistory_ARG, '\0', "nohistory", NULL, 0, 0)
arg(nolocking_ARG, '\0', "nolocking", NULL, 0, 0)
arg(norestorefile_ARG, '\0', "norestorefile", NULL, 0, 0)
arg(nosuffix_ARG, '\0', "nosuffix", NULL, 0, 0)
arg(nosync_ARG, '\0', "nosync", NULL, 0, 0)
arg(notifydbus_ARG, '\0', "notifydbus", NULL, 0, 0)
arg(noudevsync_ARG, '\0', "noudevsync", NULL, 0, 0)
arg(originname_ARG, '\0', "originname", string_arg, 0, 0)
arg(physicalvolumesize_ARG, '\0', "setphysicalvolumesize", size_mb_arg, 0, 0)
arg(poll_ARG, '\0', "poll", yes_no_arg, 0, 0)
arg(polloperation_ARG, '\0', "polloperation", string_arg, 0, 0)
arg(pooldatasize_ARG, '\0', "pooldatasize", size_mb_arg, 0, 0)
arg(poolmetadata_ARG, '\0', "poolmetadata", string_arg, 0, 0)
arg(poolmetadatasize_ARG, '\0', "poolmetadatasize", size_mb_arg, 0, 0)
arg(poolmetadataspare_ARG, '\0', "poolmetadataspare", yes_no_arg, 0, 0)
arg(profile_ARG, '\0', "profile", string_arg, 0, 0)
arg(pvmetadatacopies_ARG, '\0', "pvmetadatacopies", int_arg, 0, 0)
arg(raidrebuild_ARG, '\0', "raidrebuild", string_arg, ARG_GROUPABLE, 0)
arg(raidmaxrecoveryrate_ARG, '\0', "raidmaxrecoveryrate", size_kb_arg, 0, 0)
arg(raidminrecoveryrate_ARG, '\0', "raidminrecoveryrate", size_kb_arg, 0, 0)
arg(raidsyncaction_ARG, '\0', "raidsyncaction", string_arg, 0, 0)
arg(raidwritebehind_ARG, '\0', "raidwritebehind", int_arg, 0, 0)
arg(raidwritemostly_ARG, '\0', "raidwritemostly", string_arg, ARG_GROUPABLE, 0)
arg(readonly_ARG, '\0', "readonly", NULL, 0, 0)
arg(refresh_ARG, '\0', "refresh", NULL, 0, 0)
arg(removemissing_ARG, '\0', "removemissing", NULL, 0, 0)
arg(rebuild_ARG, '\0', "rebuild", string_arg, ARG_GROUPABLE, 0)
arg(repair_ARG, '\0', "repair", NULL, 0, 0)
arg(replace_ARG, '\0', "replace", string_arg, ARG_GROUPABLE, 0)
arg(reportformat_ARG, '\0', "reportformat", string_arg, 0, 0)
arg(restorefile_ARG, '\0', "restorefile", string_arg, 0, 0)
arg(restoremissing_ARG, '\0', "restoremissing", NULL, 0, 0)
arg(resync_ARG, '\0', "resync", NULL, 0, 0)
arg(rows_ARG, '\0', "rows", NULL, 0, 0)
arg(segments_ARG, '\0', "segments", NULL, 0, 0)
arg(separator_ARG, '\0', "separator", string_arg, 0, 0)
arg(shared_ARG, '\0', "shared", NULL, 0, 0)
arg(sinceversion_ARG, '\0', "sinceversion", string_arg, 0, 0)
arg(split_ARG, '\0', "split", NULL, 0, 0)
arg(splitcache_ARG, '\0', "splitcache", NULL, 0, 0)
arg(splitmirrors_ARG, '\0', "splitmirrors", int_arg, 0, 0)
arg(splitsnapshot_ARG, '\0', "splitsnapshot", NULL, 0, 0)
arg(showdeprecated_ARG, '\0', "showdeprecated", NULL, 0, 0)
arg(showunsupported_ARG, '\0', "showunsupported", NULL, 0, 0)
arg(stripes_long_ARG, '\0', "stripes", int_arg, 0, 0)
arg(syncaction_ARG, '\0', "syncaction", string_arg, 0, 0) /* FIXME Use custom validation fn */
arg(sysinit_ARG, '\0', "sysinit", NULL, 0, 0)
arg(systemid_ARG, '\0', "systemid", string_arg, 0, 0)
arg(thinpool_ARG, '\0', "thinpool", string_arg, 0, 0)
arg(trackchanges_ARG, '\0', "trackchanges", NULL, 0, 0)
arg(trustcache_ARG, '\0', "trustcache", NULL, 0, 0)
arg(type_ARG, '\0', "type", segtype_arg, 0, 0)
arg(unbuffered_ARG, '\0', "unbuffered", NULL, 0, 0)
arg(uncache_ARG, '\0', "uncache", NULL, 0, 0)
arg(cachepolicy_ARG, '\0', "cachepolicy", string_arg, 0, 0)
arg(cachesettings_ARG, '\0', "cachesettings", string_arg, ARG_GROUPABLE, 0)
arg(unconfigured_ARG, '\0', "unconfigured", NULL, 0, 0)
arg(units_ARG, '\0', "units", string_arg, 0, 0)
arg(unquoted_ARG, '\0', "unquoted", NULL, 0, 0)
arg(usepolicies_ARG, '\0', "usepolicies", NULL, 0, 0)
arg(validate_ARG, '\0', "validate", NULL, 0, 0)
arg(version_ARG, '\0', "version", NULL, 0, 0)
arg(vgmetadatacopies_ARG, '\0', "vgmetadatacopies", metadatacopies_arg, 0, 0)
arg(virtualoriginsize_ARG, '\0', "virtualoriginsize", size_mb_arg, 0, 0)
arg(withsummary_ARG, '\0', "withsummary", NULL, 0, 0)
arg(withcomments_ARG, '\0', "withcomments", NULL, 0, 0)
arg(withspaces_ARG, '\0', "withspaces", NULL, 0, 0)
arg(withversions_ARG, '\0', "withversions", NULL, 0, 0)
arg(writebehind_ARG, '\0', "writebehind", int_arg, 0, 0)
arg(writemostly_ARG, '\0', "writemostly", string_arg, ARG_GROUPABLE, 0)
arg(abort_ARG, '\0', "abort", 0, 0, 0)
arg(activationmode_ARG, '\0', "activationmode", activationmode_VAL, 0, 0)
arg(addtag_ARG, '\0', "addtag", tag_VAL, ARG_GROUPABLE, 0)
arg(aligned_ARG, '\0', "aligned", 0, 0, 0)
arg(alloc_ARG, '\0', "alloc", alloc_VAL, 0, 0)
arg(atomic_ARG, '\0', "atomic", 0, 0, 0)
arg(atversion_ARG, '\0', "atversion", string_VAL, 0, 0)
arg(binary_ARG, '\0', "binary", 0, 0, 0)
arg(bootloaderareasize_ARG, '\0', "bootloaderareasize", sizemb_VAL, 0, 0)
arg(cache_long_ARG, '\0', "cache", 0, 0, 0)
arg(cachemode_ARG, '\0', "cachemode", cachemode_VAL, 0, 0)
arg(cachepool_ARG, '\0', "cachepool", lv_VAL, 0, 0)
arg(commandprofile_ARG, '\0', "commandprofile", string_VAL, 0, 0)
arg(config_ARG, '\0', "config", string_VAL, 0, 0)
arg(configreport_ARG, '\0', "configreport", string_VAL, ARG_GROUPABLE, 1)
arg(configtype_ARG, '\0', "typeconfig", string_VAL, 0, 0)
arg(corelog_ARG, '\0', "corelog", 0, 0, 0)
arg(dataalignment_ARG, '\0', "dataalignment", sizekb_VAL, 0, 0)
arg(dataalignmentoffset_ARG, '\0', "dataalignmentoffset", sizekb_VAL, 0, 0)
arg(deltag_ARG, '\0', "deltag", tag_VAL, ARG_GROUPABLE, 0)
arg(detachprofile_ARG, '\0', "detachprofile", 0, 0, 0)
arg(discards_ARG, '\0', "discards", discards_VAL, 0, 0)
arg(driverloaded_ARG, '\0', "driverloaded", bool_VAL, 0, 0)
arg(errorwhenfull_ARG, '\0', "errorwhenfull", bool_VAL, 0, 0)
arg(force_long_ARG, '\0', "force", 0, ARG_COUNTABLE, 0)
arg(foreign_ARG, '\0', "foreign", 0, 0, 0)
arg(handlemissingpvs_ARG, '\0', "handlemissingpvs", 0, 0, 0)
arg(ignoreadvanced_ARG, '\0', "ignoreadvanced", 0, 0, 0)
arg(ignorelocal_ARG, '\0', "ignorelocal", 0, 0, 0)
arg(ignorelockingfailure_ARG, '\0', "ignorelockingfailure", 0, 0, 0)
arg(ignoremonitoring_ARG, '\0', "ignoremonitoring", 0, 0, 0)
arg(ignoreskippedcluster_ARG, '\0', "ignoreskippedcluster", 0, 0, 0)
arg(ignoreunsupported_ARG, '\0', "ignoreunsupported", 0, 0, 0)
arg(labelsector_ARG, '\0', "labelsector", number_VAL, 0, 0)
arg(lockopt_ARG, '\0', "lockopt", string_VAL, 0, 0)
arg(lockstart_ARG, '\0', "lockstart", 0, 0, 0)
arg(lockstop_ARG, '\0', "lockstop", 0, 0, 0)
arg(locktype_ARG, '\0', "locktype", locktype_VAL, 0, 0)
arg(logonly_ARG, '\0', "logonly", 0, 0, 0)
arg(maxrecoveryrate_ARG, '\0', "maxrecoveryrate", sizekb_VAL, 0, 0)
arg(merge_ARG, '\0', "merge", 0, 0, 0)
arg(mergedconfig_ARG, '\0', "mergedconfig", 0, 0, 0)
arg(metadatacopies_ARG, '\0', "metadatacopies", metadatacopies_VAL, 0, 0)
arg(metadataignore_ARG, '\0', "metadataignore", bool_VAL, 0, 0)
arg(metadataprofile_ARG, '\0', "metadataprofile", string_VAL, 0, 0)
arg(metadatasize_ARG, '\0', "metadatasize", sizemb_VAL, 0, 0)
arg(minor_ARG, '\0', "minor", number_VAL, ARG_GROUPABLE, 0)
arg(minrecoveryrate_ARG, '\0', "minrecoveryrate", sizekb_VAL, 0, 0)
arg(mirrorlog_ARG, '\0', "mirrorlog", mirrorlog_VAL, 0, 0)
arg(mirrorsonly_ARG, '\0', "mirrorsonly", 0, 0, 0)
arg(mknodes_ARG, '\0', "mknodes", 0, 0, 0)
arg(monitor_ARG, '\0', "monitor", bool_VAL, 0, 0)
arg(nameprefixes_ARG, '\0', "nameprefixes", 0, 0, 0)
arg(noheadings_ARG, '\0', "noheadings", 0, 0, 0)
arg(nohistory_ARG, '\0', "nohistory", 0, 0, 0)
arg(nolocking_ARG, '\0', "nolocking", 0, 0, 0)
arg(norestorefile_ARG, '\0', "norestorefile", 0, 0, 0)
arg(nosuffix_ARG, '\0', "nosuffix", 0, 0, 0)
arg(nosync_ARG, '\0', "nosync", 0, 0, 0)
arg(notifydbus_ARG, '\0', "notifydbus", 0, 0, 0)
arg(noudevsync_ARG, '\0', "noudevsync", 0, 0, 0)
arg(originname_ARG, '\0', "originname", lv_VAL, 0, 0)
arg(physicalvolumesize_ARG, '\0', "setphysicalvolumesize", sizemb_VAL, 0, 0)
arg(poll_ARG, '\0', "poll", bool_VAL, 0, 0)
arg(polloperation_ARG, '\0', "polloperation", string_VAL, 0, 0)
arg(pooldatasize_ARG, '\0', "pooldatasize", sizemb_VAL, 0, 0)
arg(poolmetadata_ARG, '\0', "poolmetadata", lv_VAL, 0, 0)
arg(poolmetadatasize_ARG, '\0', "poolmetadatasize", sizemb_VAL, 0, 0)
arg(poolmetadataspare_ARG, '\0', "poolmetadataspare", bool_VAL, 0, 0)
arg(profile_ARG, '\0', "profile", string_VAL, 0, 0)
arg(pvmetadatacopies_ARG, '\0', "pvmetadatacopies", number_VAL, 0, 0)
arg(raidrebuild_ARG, '\0', "raidrebuild", string_VAL, ARG_GROUPABLE, 0)
arg(raidmaxrecoveryrate_ARG, '\0', "raidmaxrecoveryrate", sizekb_VAL, 0, 0)
arg(raidminrecoveryrate_ARG, '\0', "raidminrecoveryrate", sizekb_VAL, 0, 0)
arg(raidsyncaction_ARG, '\0', "raidsyncaction", string_VAL, 0, 0)
arg(raidwritebehind_ARG, '\0', "raidwritebehind", number_VAL, 0, 0)
arg(raidwritemostly_ARG, '\0', "raidwritemostly", string_VAL, ARG_GROUPABLE, 0)
arg(readonly_ARG, '\0', "readonly", 0, 0, 0)
arg(refresh_ARG, '\0', "refresh", 0, 0, 0)
arg(removemissing_ARG, '\0', "removemissing", 0, 0, 0)
arg(rebuild_ARG, '\0', "rebuild", pv_VAL, ARG_GROUPABLE, 0)
arg(repair_ARG, '\0', "repair", 0, 0, 0)
arg(replace_ARG, '\0', "replace", pv_VAL, ARG_GROUPABLE, 0)
arg(reportformat_ARG, '\0', "reportformat", string_VAL, 0, 0)
arg(restorefile_ARG, '\0', "restorefile", string_VAL, 0, 0)
arg(restoremissing_ARG, '\0', "restoremissing", 0, 0, 0)
arg(resync_ARG, '\0', "resync", 0, 0, 0)
arg(rows_ARG, '\0', "rows", 0, 0, 0)
arg(segments_ARG, '\0', "segments", 0, 0, 0)
arg(separator_ARG, '\0', "separator", string_VAL, 0, 0)
arg(shared_ARG, '\0', "shared", 0, 0, 0)
arg(sinceversion_ARG, '\0', "sinceversion", string_VAL, 0, 0)
arg(split_ARG, '\0', "split", 0, 0, 0)
arg(splitcache_ARG, '\0', "splitcache", 0, 0, 0)
arg(splitmirrors_ARG, '\0', "splitmirrors", number_VAL, 0, 0)
arg(splitsnapshot_ARG, '\0', "splitsnapshot", 0, 0, 0)
arg(showdeprecated_ARG, '\0', "showdeprecated", 0, 0, 0)
arg(showunsupported_ARG, '\0', "showunsupported", 0, 0, 0)
arg(stripes_long_ARG, '\0', "stripes", number_VAL, 0, 0)
arg(syncaction_ARG, '\0', "syncaction", string_VAL, 0, 0) /* FIXME Use custom VAL */
arg(sysinit_ARG, '\0', "sysinit", 0, 0, 0)
arg(systemid_ARG, '\0', "systemid", string_VAL, 0, 0)
arg(thinpool_ARG, '\0', "thinpool", lv_VAL, 0, 0)
arg(trackchanges_ARG, '\0', "trackchanges", 0, 0, 0)
arg(trustcache_ARG, '\0', "trustcache", 0, 0, 0)
arg(type_ARG, '\0', "type", segtype_VAL, 0, 0)
arg(unbuffered_ARG, '\0', "unbuffered", 0, 0, 0)
arg(uncache_ARG, '\0', "uncache", 0, 0, 0)
arg(cachepolicy_ARG, '\0', "cachepolicy", string_VAL, 0, 0)
arg(cachesettings_ARG, '\0', "cachesettings", string_VAL, ARG_GROUPABLE, 0)
arg(unconfigured_ARG, '\0', "unconfigured", 0, 0, 0)
arg(units_ARG, '\0', "units", units_VAL, 0, 0)
arg(unquoted_ARG, '\0', "unquoted", 0, 0, 0)
arg(usepolicies_ARG, '\0', "usepolicies", 0, 0, 0)
arg(validate_ARG, '\0', "validate", 0, 0, 0)
arg(version_ARG, '\0', "version", 0, 0, 0)
arg(vgmetadatacopies_ARG, '\0', "vgmetadatacopies", metadatacopies_VAL, 0, 0)
arg(virtualoriginsize_ARG, '\0', "virtualoriginsize", sizemb_VAL, 0, 0)
arg(withsummary_ARG, '\0', "withsummary", 0, 0, 0)
arg(withcomments_ARG, '\0', "withcomments", 0, 0, 0)
arg(withspaces_ARG, '\0', "withspaces", 0, 0, 0)
arg(withversions_ARG, '\0', "withversions", 0, 0, 0)
arg(writebehind_ARG, '\0', "writebehind", number_VAL, 0, 0)
arg(writemostly_ARG, '\0', "writemostly", string_VAL, ARG_GROUPABLE, 0)
/* Allow some variations */
arg(allocation_ARG, '\0', "allocation", yes_no_arg, 0, 0)
arg(available_ARG, '\0', "available", activation_arg, 0, 0)
arg(resizable_ARG, '\0', "resizable", yes_no_arg, 0, 0)
arg(allocation_ARG, '\0', "allocation", bool_VAL, 0, 0)
arg(available_ARG, '\0', "available", activation_VAL, 0, 0)
arg(resizable_ARG, '\0', "resizable", bool_VAL, 0, 0)
/*
* ... and now the short args.
*/
arg(activate_ARG, 'a', "activate", activation_arg, 0, 0)
arg(all_ARG, 'a', "all", NULL, 0, 0)
arg(autobackup_ARG, 'A', "autobackup", yes_no_arg, 0, 0)
arg(activevolumegroups_ARG, 'A', "activevolumegroups", NULL, 0, 0)
arg(background_ARG, 'b', "background", NULL, 0, 0)
arg(backgroundfork_ARG, 'b', "background", NULL, 0, 0)
arg(basevgname_ARG, 'n', "basevgname", string_arg, 0, 0)
arg(blockdevice_ARG, 'b', "blockdevice", NULL, 0, 0)
arg(chunksize_ARG, 'c', "chunksize", size_kb_arg, 0, 0)
arg(clustered_ARG, 'c', "clustered", yes_no_arg, 0, 0)
arg(colon_ARG, 'c', "colon", NULL, 0, 0)
arg(columns_ARG, 'C', "columns", NULL, 0, 0)
arg(contiguous_ARG, 'C', "contiguous", yes_no_arg, 0, 0)
arg(debug_ARG, 'd', "debug", NULL, ARG_COUNTABLE, 0)
arg(exported_ARG, 'e', "exported", NULL, 0, 0)
arg(physicalextent_ARG, 'E', "physicalextent", NULL, 0, 0)
arg(file_ARG, 'f', "file", string_arg, 0, 0)
arg(force_ARG, 'f', "force", NULL, ARG_COUNTABLE, 0)
arg(full_ARG, 'f', "full", NULL, 0, 0)
arg(help_ARG, 'h', "help", NULL, ARG_COUNTABLE, 0)
arg(cache_ARG, 'H', "cache", NULL, 0, 0)
arg(history_ARG, 'H', "history", NULL, 0, 0)
arg(help2_ARG, '?', "", NULL, 0, 0)
arg(import_ARG, 'i', "import", NULL, 0, 0)
arg(interval_ARG, 'i', "interval", int_arg, 0, 0)
arg(iop_version_ARG, 'i', "iop_version", NULL, 0, 0)
arg(stripes_ARG, 'i', "stripes", int_arg, 0, 0)
arg(stripesize_ARG, 'I', "stripesize", size_kb_arg, 0, 0)
arg(logicalvolume_ARG, 'l', "logicalvolume", int_arg, 0, 0)
arg(maxlogicalvolumes_ARG, 'l', "maxlogicalvolumes", int_arg, 0, 0)
arg(extents_ARG, 'l', "extents", int_arg_with_sign_and_percent, 0, 0)
arg(list_ARG, 'l', "list", NULL, 0, 0)
arg(lvmpartition_ARG, 'l', "lvmpartition", NULL, 0, 0)
arg(logicalextent_ARG, 'L', "logicalextent", int_arg_with_sign, 0, 0)
arg(size_ARG, 'L', "size", size_mb_arg, 0, 0)
arg(persistent_ARG, 'M', "persistent", yes_no_arg, 0, 0)
arg(major_ARG, 'j', "major", int_arg, ARG_GROUPABLE, 0)
arg(setactivationskip_ARG, 'k', "setactivationskip", yes_no_arg, 0, 0)
arg(ignoreactivationskip_ARG, 'K', "ignoreactivationskip", NULL, 0, 0)
arg(maps_ARG, 'm', "maps", NULL, 0, 0)
arg(mirrors_ARG, 'm', "mirrors", int_arg_with_sign, 0, 0)
arg(metadatatype_ARG, 'M', "metadatatype", metadatatype_arg, 0, 0)
arg(name_ARG, 'n', "name", string_arg, 0, 0)
arg(nofsck_ARG, 'n', "nofsck", NULL, 0, 0)
arg(novolumegroup_ARG, 'n', "novolumegroup", NULL, 0, 0)
arg(oldpath_ARG, 'n', "oldpath", NULL, 0, 0)
arg(options_ARG, 'o', "options", string_arg, ARG_GROUPABLE, 0)
arg(sort_ARG, 'O', "sort", string_arg, ARG_GROUPABLE, 0)
arg(maxphysicalvolumes_ARG, 'p', "maxphysicalvolumes", int_arg, 0, 0)
arg(permission_ARG, 'p', "permission", permission_arg, 0, 0)
arg(partial_ARG, 'P', "partial", NULL, 0, 0)
arg(physicalvolume_ARG, 'P', "physicalvolume", NULL, 0, 0)
arg(quiet_ARG, 'q', "quiet", NULL, ARG_COUNTABLE, 0)
arg(readahead_ARG, 'r', "readahead", readahead_arg, 0, 0)
arg(resizefs_ARG, 'r', "resizefs", NULL, 0, 0)
arg(reset_ARG, 'R', "reset", NULL, 0, 0)
arg(regionsize_ARG, 'R', "regionsize", size_mb_arg, 0, 0)
arg(physicalextentsize_ARG, 's', "physicalextentsize", size_mb_arg, 0, 0)
arg(snapshot_ARG, 's', "snapshot", NULL, 0, 0)
arg(short_ARG, 's', "short", NULL, 0, 0)
arg(stdin_ARG, 's', "stdin", NULL, 0, 0)
arg(select_ARG, 'S', "select", string_arg, ARG_GROUPABLE, 0)
arg(test_ARG, 't', "test", NULL, 0, 0)
arg(thin_ARG, 'T', "thin", NULL, 0, 0)
arg(uuid_ARG, 'u', "uuid", NULL, 0, 0)
arg(uuidstr_ARG, 'u', "uuid", string_arg, 0, 0)
arg(uuidlist_ARG, 'U', "uuidlist", NULL, 0, 0)
arg(verbose_ARG, 'v', "verbose", NULL, ARG_COUNTABLE, 0)
arg(volumegroup_ARG, 'V', "volumegroup", NULL, 0, 0)
arg(virtualsize_ARG, 'V', "virtualsize", size_mb_arg, 0, 0)
arg(wipesignatures_ARG, 'W', "wipesignatures", yes_no_arg, 0, 0)
arg(allocatable_ARG, 'x', "allocatable", yes_no_arg, 0, 0)
arg(resizeable_ARG, 'x', "resizeable", yes_no_arg, 0, 0)
arg(yes_ARG, 'y', "yes", NULL, 0, 0)
arg(zero_ARG, 'Z', "zero", yes_no_arg, 0, 0)
arg(activate_ARG, 'a', "activate", activation_VAL, 0, 0)
arg(all_ARG, 'a', "all", 0, 0, 0)
arg(autobackup_ARG, 'A', "autobackup", bool_VAL, 0, 0)
arg(activevolumegroups_ARG, 'A', "activevolumegroups", 0, 0, 0)
arg(background_ARG, 'b', "background", 0, 0, 0)
arg(backgroundfork_ARG, 'b', "background", 0, 0, 0)
arg(basevgname_ARG, 'n', "basevgname", string_VAL, 0, 0)
arg(blockdevice_ARG, 'b', "blockdevice", 0, 0, 0)
arg(chunksize_ARG, 'c', "chunksize", sizekb_VAL, 0, 0)
arg(clustered_ARG, 'c', "clustered", bool_VAL, 0, 0)
arg(colon_ARG, 'c', "colon", 0, 0, 0)
arg(columns_ARG, 'C', "columns", 0, 0, 0)
arg(contiguous_ARG, 'C', "contiguous", bool_VAL, 0, 0)
arg(debug_ARG, 'd', "debug", 0, ARG_COUNTABLE, 0)
arg(exported_ARG, 'e', "exported", 0, 0, 0)
arg(physicalextent_ARG, 'E', "physicalextent", 0, 0, 0)
arg(file_ARG, 'f', "file", string_VAL, 0, 0)
arg(force_ARG, 'f', "force", 0, ARG_COUNTABLE, 0)
arg(full_ARG, 'f', "full", 0, 0, 0)
arg(help_ARG, 'h', "help", 0, ARG_COUNTABLE, 0)
arg(cache_ARG, 'H', "cache", 0, 0, 0)
arg(history_ARG, 'H', "history", 0, 0, 0)
arg(help2_ARG, '?', "", 0, 0, 0)
arg(import_ARG, 'i', "import", 0, 0, 0)
arg(interval_ARG, 'i', "interval", number_VAL, 0, 0)
arg(iop_version_ARG, 'i', "iop_version", 0, 0, 0)
arg(stripes_ARG, 'i', "stripes", number_VAL, 0, 0)
arg(stripesize_ARG, 'I', "stripesize", sizekb_VAL, 0, 0)
arg(logicalvolume_ARG, 'l', "logicalvolume", number_VAL, 0, 0)
arg(maxlogicalvolumes_ARG, 'l', "maxlogicalvolumes", number_VAL, 0, 0)
arg(extents_ARG, 'l', "extents", numsignedper_VAL, 0, 0)
arg(list_ARG, 'l', "list", 0, 0, 0)
arg(lvmpartition_ARG, 'l', "lvmpartition", 0, 0, 0)
arg(size_ARG, 'L', "size", sizemb_VAL, 0, 0)
arg(persistent_ARG, 'M', "persistent", bool_VAL, 0, 0)
arg(major_ARG, 'j', "major", number_VAL, ARG_GROUPABLE, 0)
arg(setactivationskip_ARG, 'k', "setactivationskip", bool_VAL, 0, 0)
arg(ignoreactivationskip_ARG, 'K', "ignoreactivationskip", 0, 0, 0)
arg(maps_ARG, 'm', "maps", 0, 0, 0)
arg(mirrors_ARG, 'm', "mirrors", numsigned_VAL, 0, 0)
arg(metadatatype_ARG, 'M', "metadatatype", metadatatype_VAL, 0, 0)
arg(name_ARG, 'n', "name", string_VAL, 0, 0)
arg(nofsck_ARG, 'n', "nofsck", 0, 0, 0)
arg(novolumegroup_ARG, 'n', "novolumegroup", 0, 0, 0)
arg(oldpath_ARG, 'n', "oldpath", 0, 0, 0)
arg(options_ARG, 'o', "options", string_VAL, ARG_GROUPABLE, 0)
arg(sort_ARG, 'O', "sort", string_VAL, ARG_GROUPABLE, 0)
arg(maxphysicalvolumes_ARG, 'p', "maxphysicalvolumes", number_VAL, 0, 0)
arg(permission_ARG, 'p', "permission", permission_VAL, 0, 0)
arg(partial_ARG, 'P', "partial", 0, 0, 0)
arg(physicalvolume_ARG, 'P', "physicalvolume", 0, 0, 0)
arg(quiet_ARG, 'q', "quiet", 0, ARG_COUNTABLE, 0)
arg(readahead_ARG, 'r', "readahead", readahead_VAL, 0, 0)
arg(resizefs_ARG, 'r', "resizefs", 0, 0, 0)
arg(reset_ARG, 'R', "reset", 0, 0, 0)
arg(regionsize_ARG, 'R', "regionsize", sizemb_VAL, 0, 0)
arg(physicalextentsize_ARG, 's', "physicalextentsize", sizemb_VAL, 0, 0)
arg(snapshot_ARG, 's', "snapshot", 0, 0, 0)
arg(short_ARG, 's', "short", 0, 0, 0)
arg(stdin_ARG, 's', "stdin", 0, 0, 0)
arg(select_ARG, 'S', "select", string_VAL, ARG_GROUPABLE, 0)
arg(test_ARG, 't', "test", 0, 0, 0)
arg(thin_ARG, 'T', "thin", 0, 0, 0)
arg(uuid_ARG, 'u', "uuid", 0, 0, 0)
arg(uuidstr_ARG, 'u', "uuid", string_VAL, 0, 0)
arg(uuidlist_ARG, 'U', "uuidlist", 0, 0, 0)
arg(verbose_ARG, 'v', "verbose", 0, ARG_COUNTABLE, 0)
arg(volumegroup_ARG, 'V', "volumegroup", 0, 0, 0)
arg(virtualsize_ARG, 'V', "virtualsize", sizemb_VAL, 0, 0)
arg(wipesignatures_ARG, 'W', "wipesignatures", bool_VAL, 0, 0)
arg(allocatable_ARG, 'x', "allocatable", bool_VAL, 0, 0)
arg(resizeable_ARG, 'x', "resizeable", bool_VAL, 0, 0)
arg(yes_ARG, 'y', "yes", 0, 0, 0)
arg(zero_ARG, 'Z', "zero", bool_VAL, 0, 0)
/* this should always be last */
arg(ARG_COUNT, '-', "", NULL, 0, 0)
arg(ARG_COUNT, '-', "", 0, 0, 0)
/* *INDENT-ON* */

File diff suppressed because it is too large Load Diff

View File

@@ -32,58 +32,48 @@ typedef int (*command_fn) (struct cmd_context * cmd, int argc, char **argv);
* The first positional arg has pos_arg.pos of 1.
*/
/* Number of string constants accepted after an option. */
#define MAX_STR_SET 16
/* arg_def flags */
#define ARG_DEF_FLAG_NEW 1
#define ARG_DEF_FLAG_MAY_REPEAT 2
#define ARG_DEF_FLAG_NEW 1 << 0
#define ARG_DEF_FLAG_MAY_REPEAT 1 << 1
/* arg_def types, can be multiple */
/* arg_def lv_types */
enum {
ARG_DEF_TYPE_NONE = 0,
ARG_DEF_TYPE_BOOL = 1 << 0,
ARG_DEF_TYPE_NUM_ANY = 1 << 1,
ARG_DEF_TYPE_STR_ANY = 1 << 2,
ARG_DEF_TYPE_NUM_CONST = 1 << 3,
ARG_DEF_TYPE_STR_CONST = 1 << 4,
ARG_DEF_TYPE_STR_SET = 1 << 5,
ARG_DEF_TYPE_NAME_ANY = 1 << 6,
ARG_DEF_TYPE_NAME_PV = 1 << 7,
ARG_DEF_TYPE_NAME_VG = 1 << 8,
ARG_DEF_TYPE_NAME_LV = 1 << 9,
ARG_DEF_TYPE_TAG = 1 << 10,
ARG_DEF_TYPE_SELECT = 1 << 11,
ARG_DEF_LV_ANY = 0,
ARG_DEF_LV_LINEAR = 1 << 0,
ARG_DEF_LV_STRIPED = 1 << 1,
ARG_DEF_LV_SNAPSHOT = 1 << 2,
ARG_DEF_LV_MIRROR = 1 << 3,
ARG_DEF_LV_RAID = 1 << 4,
ARG_DEF_LV_RAID0 = 1 << 5,
ARG_DEF_LV_RAID1 = 1 << 6,
ARG_DEF_LV_RAID4 = 1 << 7,
ARG_DEF_LV_RAID5 = 1 << 8,
ARG_DEF_LV_RAID6 = 1 << 9,
ARG_DEF_LV_RAID10 = 1 << 10,
ARG_DEF_LV_THIN = 1 << 11,
ARG_DEF_LV_THINPOOL = 1 << 12,
ARG_DEF_LV_CACHE = 1 << 13,
ARG_DEF_LV_CACHEPOOL = 1 << 14,
ARG_DEF_LV_LAST = 1 << 15,
};
/* arg_def lv_types, can be multiple */
enum {
ARG_DEF_LV_ANY = 0,
ARG_DEF_LV_LINEAR = 1 << 0,
ARG_DEF_LV_STRIPED = 1 << 1,
ARG_DEF_LV_SNAPSHOT = 1 << 2,
ARG_DEF_LV_MIRROR = 1 << 3,
ARG_DEF_LV_RAID = 1 << 4,
ARG_DEF_LV_RAID0 = 1 << 5,
ARG_DEF_LV_RAID1 = 1 << 6,
ARG_DEF_LV_RAID4 = 1 << 7,
ARG_DEF_LV_RAID5 = 1 << 8,
ARG_DEF_LV_RAID6 = 1 << 9,
ARG_DEF_LV_RAID10 = 1 << 10,
ARG_DEF_LV_THIN = 1 << 11,
ARG_DEF_LV_THINPOOL = 1 << 12,
ARG_DEF_LV_CACHE = 1 << 13,
ARG_DEF_LV_CACHEPOOL = 1 << 14,
};
static inline int val_bit_is_set(uint64_t val_bits, int val_enum)
{
return (val_bits & (1 << val_enum)) ? 1 : 0;
}
static inline uint64_t val_enum_to_bit(int val_enum)
{
return 1 << val_enum;
}
/* Description a value that follows an option or exists in a position. */
struct arg_def {
uint32_t types; /* ARG_DEF_TYPE_, can be multiple */
uint32_t lv_types; /* ARG_DEF_LV_, can be multiple */
uint64_t num; /* a literal number for ARG_DEF_TYPE_NUM_CONST */
const char *str; /* a literal string for ARG_DEF_TYPE_STR_CONST */
const char *str_set[MAX_STR_SET]; /* literal strings for ARG_DEF_TYPE_STR_SET */
uint64_t val_bits; /* bits of x_VAL, can be multiple for pos_arg */
uint64_t num; /* a literal number for conststr_VAL */
const char *str; /* a literal string for constnum_VAL */
uint32_t lv_types; /* ARG_DEF_LV_, for lv_VAL, can be multiple */
uint32_t flags; /* ARG_DEF_FLAG_ */
};
@@ -121,7 +111,8 @@ struct pos_arg {
struct command {
const char *name;
const char *desc; /* specific command description from command-lines.h */
const char *usage;
const char *usage; /* excludes common options like --help, --debug */
const char *usage_common; /* includes commmon options like --help, --debug */
struct command_name *cname;
command_fn fn;

View File

@@ -57,7 +57,7 @@ int lvm2_run(void *handle, const char *cmdline)
cmd = (struct cmd_context *) handle;
cmd->pos_arg_values = argv;
cmd->argv = argv;
if (!(cmdcopy = dm_strdup(cmdline))) {
log_error("Cmdline copy failed.");

View File

@@ -52,7 +52,16 @@ extern char *optarg;
#include "command-lines-count.h" /* #define COMMAND_COUNT, generated from command-lines.in */
/*
* Table of valid switches
* Table of valid --option values.
*/
static struct val_props _val_props[VAL_COUNT + 1] = {
#define val(a, b, c, d) {a, b, c, d},
#include "vals.h"
#undef val
};
/*
* Table of valid --option's
*/
static struct arg_props _arg_props[ARG_COUNT + 1] = {
#define arg(a, b, c, d, e, f) {a, b, "", "--" c, d, e, f},
@@ -735,7 +744,7 @@ static void _set_valid_args_for_command_name(int ci)
{
int all_args[ARG_COUNT] = { 0 };
int num_args = 0;
int opt_enum_val;
int opt_enum; /* foo_ARG from args.h */
int i, ro, oo;
/*
@@ -747,18 +756,18 @@ static void _set_valid_args_for_command_name(int ci)
continue;
for (ro = 0; ro < commands[i].ro_count; ro++) {
opt_enum_val = commands[i].required_opt_args[ro].opt;
all_args[opt_enum_val] = 1;
opt_enum = commands[i].required_opt_args[ro].opt;
all_args[opt_enum] = 1;
}
for (oo = 0; oo < commands[i].oo_count; oo++) {
opt_enum_val = commands[i].optional_opt_args[oo].opt;
all_args[opt_enum_val] = 1;
opt_enum = commands[i].optional_opt_args[oo].opt;
all_args[opt_enum] = 1;
}
}
for (i = 0; i < ARG_COUNT; i++) {
if (all_args[i]) {
command_names[ci].valid_args[num_args] = _cmdline.arg_props[i].enum_val;
command_names[ci].valid_args[num_args] = _cmdline.arg_props[i].arg_enum;
num_args++;
}
}
@@ -833,8 +842,8 @@ void lvm_register_commands(void)
* any one item from commands[i].required_opt_args needs to be
* set to match.
*
* required_pos_args[0].flags & ARG_DEF_TYPE_SELECT means
* cmd->pos_arg_values[0] can be NULL if arg_is_set(select_ARG)
* required_pos_args[0].types & select_VAL means
* cmd->argv[] in that pos can be NULL if arg_is_set(select_ARG)
*/
static int _opt_equivalent_is_set(struct cmd_context *cmd, int opt)
@@ -877,32 +886,64 @@ static int _opt_equivalent_is_set(struct cmd_context *cmd, int opt)
static int _command_required_opt_matches(struct cmd_context *cmd, int ci, int ro)
{
if (arg_is_set(cmd, commands[ci].required_opt_args[ro].opt))
return 1;
int opt_enum = commands[ci].required_opt_args[ro].opt;
if (arg_is_set(cmd, opt_enum))
goto check_val;
/*
* For some commands, --size and --extents are interchanable,
* For some commands, --size and --extents are interchangable,
* but command[] definitions use only --size.
*/
if ((commands[ci].required_opt_args[ro].opt == size_ARG) && arg_is_set(cmd, extents_ARG)) {
if ((opt_enum == size_ARG) && arg_is_set(cmd, extents_ARG)) {
if (!strcmp(commands[ci].name, "lvcreate") ||
!strcmp(commands[ci].name, "lvresize") ||
!strcmp(commands[ci].name, "lvextend") ||
!strcmp(commands[ci].name, "lvreduce"))
return 1;
goto check_val;
}
/* TODO: for lvmconfig, recognize --type in place of --typeconfig? */
if (_opt_equivalent_is_set(cmd, commands[ci].required_opt_args[ro].opt))
return 1;
if (_opt_equivalent_is_set(cmd, opt_enum))
goto check_val;
return 0;
/*
* If the definition requires a literal string or number, check
* that the arg value matches.
*/
check_val:
if (val_bit_is_set(commands[ci].required_opt_args[ro].def.val_bits, conststr_VAL)) {
if (!strcmp(commands[ci].required_opt_args[ro].def.str, arg_str_value(cmd, opt_enum, "")))
return 1;
/* Special case: "raid0" (any raid<N>), matches command def "raid" */
if (!strcmp(commands[ci].required_opt_args[ro].def.str, "raid") &&
!strncmp(arg_str_value(cmd, opt_enum, ""), "raid", 4))
return 1;
return 0;
}
if (val_bit_is_set(commands[ci].required_opt_args[ro].def.val_bits, constnum_VAL)) {
if (commands[ci].required_opt_args[ro].def.num == arg_int_value(cmd, opt_enum, 0))
return 1;
return 0;
}
return 1;
}
static int _command_required_pos_matches(struct cmd_context *cmd, int ci, int rp)
static int _command_required_pos_matches(struct cmd_context *cmd, int ci, int rp, char **argv)
{
if (cmd->pos_arg_values[rp]) {
/*
* rp is the index in required_pos_args[] of the required positional arg.
* The pos values begin with 1, so the first positional arg has
* pos 1, rp 0.
*/
if (argv[rp]) {
/* FIXME: can we match object type better than just checking something exists? */
/* Some cases could be validated by looking at defs.types and at the value. */
return 1;
@@ -912,7 +953,7 @@ static int _command_required_pos_matches(struct cmd_context *cmd, int ci, int rp
* If Select is specified as a pos arg, then that pos arg can be
* empty if --select is used.
*/
if ((commands[ci].required_pos_args[rp].def.types & ARG_DEF_TYPE_SELECT) &&
if ((val_bit_is_set(commands[ci].required_pos_args[rp].def.val_bits, select_VAL)) &&
arg_is_set(cmd, select_ARG))
return 1;
@@ -922,57 +963,42 @@ static int _command_required_pos_matches(struct cmd_context *cmd, int ci, int rp
#define HELP_LINE_SIZE 1024
static void _print_usage(int ci, int include_optional)
static void _print_usage(const char *usage)
{
const char *usage = _cmdline.commands[ci].usage;
char buf[HELP_LINE_SIZE] = {0};
char buf[HELP_LINE_SIZE];
int optional_ui = 0;
int ui = 0;
int bi = 0;
int optional_pos_ui = 0;
int ui;
int bi;
if (!usage || !strlen(usage))
return;
/*
* Print the required portions of the usage string.
* copy the required opt_args/pos_args
*
* The optional portions of the usage string are enclosed
* in [] and follow the required portions.
*
* The optional portion begins with [ followed by a space,
* i.e. "[ " to distinguish the option usage which may
* include [ in cases like --option Number[units].
*/
for (ui = 0; ui < strlen(usage); ui++) {
if (usage[ui] == '[') {
optional_ui = ui;
break;
}
if (usage[ui] == '\0')
break;
if (usage[ui] == '\n')
break;
buf[bi++] = usage[ui];
if (usage[ui] == ',') {
buf[bi++] = '\n';
buf[bi++] = '\t';
}
if (bi == (HELP_LINE_SIZE - 1))
break;
}
if (!include_optional) {
log_print("%s\n", buf);
return;
}
log_print("%s", buf);
memset(buf, 0, sizeof(buf));
bi = 0;
buf[bi++] = '\t';
for (ui = 0; ui < strlen(usage); ui++) {
if (!bi && ((usage[ui] == ' ') || (usage[ui] == '\n')))
continue;
for (ui = optional_ui; ui < strlen(usage); ui++) {
if (usage[ui] == '\0')
/* The first "[ " indicates the start of the optional opt_args. */
if ((usage[ui] == '[') && (usage[ui+1] == ' ')) {
optional_ui = ui;
break;
if (usage[ui] == '\n')
}
if (usage[ui] == '\0')
break;
buf[bi++] = usage[ui];
@@ -980,19 +1006,99 @@ static void _print_usage(int ci, int include_optional)
if (usage[ui] == ',') {
buf[bi++] = '\n';
buf[bi++] = '\t';
buf[bi++] = ' ';
}
if (bi == (HELP_LINE_SIZE - 1))
break;
}
log_print("%s\n", buf);
}
/*
* print the required opt_args/pos_args
*/
/*
* A description is a string with multiple sentences each ending in periods.
* Print each sentence on a new line.
*/
if (bi)
log_print("%s", buf);
/*
* copy the optional opt_args
*/
if (!optional_ui)
goto out;
memset(buf, 0, sizeof(buf));
bi = 0;
for (ui = optional_ui; ui < strlen(usage); ui++) {
/* The second "[ " indicates the start of the optional pos_args. */
if ((ui > optional_ui) && (usage[ui] == '[') && (usage[ui+1] == ' ')) {
optional_pos_ui = ui;
break;
}
if (usage[ui] == '\0')
break;
if (usage[ui] == '\n')
break;
if (!bi)
buf[bi++] = '\t';
buf[bi++] = usage[ui];
if (usage[ui] == ',') {
buf[bi++] = '\n';
buf[bi++] = '\t';
buf[bi++] = ' ';
}
if (bi == (HELP_LINE_SIZE - 1))
break;
}
/*
* print the optional opt_args
*/
if (bi)
log_print("%s", buf);
/*
* copy the optional pos_args
*/
if (!optional_pos_ui)
goto out;
memset(buf, 0, sizeof(buf));
bi = 0;
for (ui = optional_pos_ui; ui < strlen(usage); ui++) {
if (usage[ui] == '\0')
break;
if (usage[ui] == '\n')
break;
if (!bi)
buf[bi++] = '\t';
buf[bi++] = usage[ui];
if (bi == (HELP_LINE_SIZE - 1))
break;
}
/*
* print the optional pos_args
*/
if (bi)
log_print("%s", buf);
out:
return;
}
static void _print_description(int ci)
{
@@ -1007,31 +1113,38 @@ static void _print_description(int ci)
if (desc[di] == '\n')
continue;
if (!strncmp(&desc[di], "DESC:", 5)) {
if (bi) {
log_print("%s", buf);
memset(buf, 0, sizeof(buf));
bi = 0;
}
di += 5;
continue;
}
if (!bi && desc[di] == ' ')
continue;
buf[bi++] = desc[di];
if (desc[di] == '.') {
log_print("%s", buf);
memset(buf, 0, sizeof(buf));
bi = 0;
}
if (bi == (HELP_LINE_SIZE - 1))
break;
}
if (bi)
log_print("%s", buf);
}
static struct command *_find_command(struct cmd_context *cmd, const char *path)
static struct command *_find_command(struct cmd_context *cmd, const char *path, int *argc, char **argv)
{
const char *name;
int match_count, mismatch_count;
int best_match_i = 0, best_match_count = 0;
int match_count, match_count_ro, match_count_rp, mismatch_count;
int best_i = 0, best_count = 0;
int closest_i = 0, closest_count = 0;
int ro_matches;
int ro, rp;
int i;
int i, j;
int accepted, count;
name = last_path_component(path);
@@ -1043,16 +1156,15 @@ static struct command *_find_command(struct cmd_context *cmd, const char *path)
if (arg_is_set(cmd, help_ARG) || arg_is_set(cmd, help2_ARG) || arg_is_set(cmd, version_ARG))
return &commands[i];
match_count = 0;
mismatch_count = 0;
ro_matches = 0;
match_count = 0; /* total parameters that match */
match_count_ro = 0; /* required opt_args that match */
match_count_rp = 0; /* required pos_args that match */
mismatch_count = 0; /* total parameters that do not match */
/* if the command name alone is enough, then that's a match */
if (!commands[i].ro_count && !commands[i].rp_count) {
/* log_warn("match %d command name %s", i, name); */
if (!commands[i].ro_count && !commands[i].rp_count)
match_count = 1;
}
/* match required_opt_args */
@@ -1060,7 +1172,7 @@ static struct command *_find_command(struct cmd_context *cmd, const char *path)
if (_command_required_opt_matches(cmd, i, ro)) {
/* log_warn("match %d ro opt %d", i, commands[i].required_opt_args[ro].opt); */
match_count++;
ro_matches++;
match_count_ro++;
} else {
/* cmd is missing a required opt arg */
/* log_warn("mismatch %d ro opt %d", i, commands[i].required_opt_args[ro].opt); */
@@ -1073,7 +1185,7 @@ static struct command *_find_command(struct cmd_context *cmd, const char *path)
* if one required_opt_arg did match.
*/
if (commands[i].cmd_flags & CMD_FLAG_ONE_REQUIRED_OPT) {
if (ro_matches) {
if (match_count_ro) {
/* one or more of the required_opt_args is used */
mismatch_count = 0;
} else {
@@ -1085,9 +1197,10 @@ static struct command *_find_command(struct cmd_context *cmd, const char *path)
/* match required_pos_args */
for (rp = 0; rp < commands[i].rp_count; rp++) {
if (_command_required_pos_matches(cmd, i, rp)) {
if (_command_required_pos_matches(cmd, i, rp, argv)) {
/* log_warn("match %d rp %d", i, commands[i].required_pos_args[rp].pos); */
match_count++;
match_count_rp++;
} else {
/* cmd is missing a required pos arg */
/* log_warn("mismatch %d rp %d", i, commands[i].required_pos_args[rp].pos); */
@@ -1106,36 +1219,121 @@ static struct command *_find_command(struct cmd_context *cmd, const char *path)
continue;
}
/* use command that has the most matching required opt/pos */
if (!match_count)
continue;
if (!best_match_count || (match_count > best_match_count)) {
/* log_warn("match best i %d count %d", i, match_count); */
best_match_i = i;
best_match_count = match_count;
/* Count the command name as a match if all the required opt/pos args match. */
if ((commands[i].ro_count || commands[i].rp_count) &&
(match_count_ro || match_count_rp))
match_count++;
/* log_warn("command %d has match_count %d match_ro %d match_rp %d",
i, match_count, match_count_ro, match_count_rp); */
/*
* Choose the best match, which in general is the command with
* the most matching required_{opt,pos}.
*/
if (!best_count || (match_count > best_count)) {
/* log_warn("best %d has match_count %d match_ro %d match_rp %d",
i, match_count, match_count_ro, match_count_rp); */
best_i = i;
best_count = match_count;
}
}
if (!best_match_count) {
if (!best_count) {
/* cmd did not have all the required opt/pos args of any command */
log_error("Failed to find a matching command definition.\n");
if (closest_count) {
log_warn("Closest command usage is:");
_print_usage(closest_i, 0);
_print_usage(_cmdline.commands[closest_i].usage);
}
return NULL;
}
/*
* Check if all arg_is_set values from cmd are accepted as
* optional_opt_args, and warn (or fail per config?) if options are set
* in cmd that are not accepted by the chosen command[i].
*
* Same for pos args.
* FIXME: should there be a config setting to fail the command if an
* unused option or pos arg is set? Or a user prompt to continue or
* not without the ignored args? There are ad hoc checks in various
* commands to fail sometimes if an unused option or pos arg is set.
* Does this mean a per-command flag is needed to determine if that
* command ignores or fails with unused args? e.g. "pvscan vg" would
* fail based on the vg arg, but now it's just ignored.
*/
/* log_warn("command matched: %.256s ...", commands[best_match_i].usage); */
/*
* Warn about options that are set but are not used by the command.
*/
return &commands[best_match_i];
for (i = 0; i < ARG_COUNT; i++) {
if (!arg_is_set(cmd, i))
continue;
accepted = 0;
/* NB in some cases required_opt_args are optional */
for (j = 0; j < commands[best_i].ro_count; j++) {
if (commands[best_i].required_opt_args[j].opt == i) {
accepted = 1;
break;
}
}
if (accepted)
continue;
for (j = 0; j < commands[best_i].oo_count; j++) {
if (commands[best_i].optional_opt_args[j].opt == i) {
accepted = 1;
break;
}
}
if (!accepted) {
log_warn("Ignoring option which is not used by the specified command: %s.",
arg_long_option_name(i));
/* clear so it can't be used when processing. */
cmd->opt_arg_values[i].count = 0;
cmd->opt_arg_values[i].value = NULL;
}
}
/*
* Warn about positional args that are set but are not used by the command.
*
* If the last required_pos_arg or the last optional_pos_arg may repeat,
* then there won't be unused positional args.
*
* Otherwise, warn about positional args that exist beyond the number of
* required + optional pos_args.
*/
count = commands[best_i].rp_count;
if (count && (commands[best_i].required_pos_args[count - 1].def.flags & ARG_DEF_FLAG_MAY_REPEAT))
goto out;
count = commands[best_i].op_count;
if (count && (commands[best_i].optional_pos_args[count - 1].def.flags & ARG_DEF_FLAG_MAY_REPEAT))
goto out;
for (count = 0; ; count++) {
if (!argv[count])
break;
if (count >= (commands[best_i].rp_count + commands[best_i].op_count)) {
log_warn("Ignoring positional argument which is not used by this command: %s.", argv[count]);
/* clear so it can't be used when processing. */
argv[count] = NULL;
(*argc)--;
}
}
out:
log_debug("Command definition (%d): %s", best_i, commands[best_i].usage);
return &commands[best_i];
}
static void _short_usage(const char *name)
@@ -1146,6 +1344,7 @@ static void _short_usage(const char *name)
static int _usage(const char *name, int help_count)
{
struct command_name *cname = _find_command_name(name);
const char *usage_common = NULL;
int i;
if (!cname) {
@@ -1162,7 +1361,37 @@ static int _usage(const char *name, int help_count)
if (strlen(_cmdline.commands[i].desc))
_print_description(i);
_print_usage(i, help_count > 1);
usage_common = _cmdline.commands[i].usage_common;
_print_usage(_cmdline.commands[i].usage);
log_print(" "); /* for built-in \n */
}
/* Common options are printed once for all variants of a command name. */
if (usage_common) {
log_print("Common options:");
_print_usage(usage_common);
log_print(" "); /* for built-in \n */
}
if (help_count > 1) {
/*
* Excluding commonly understood syntax style like the meanings of:
* [ ] for optional, ... for repeatable, | for one of the following,
* -- for an option name, lower case strings and digits for literals.
*/
log_print("Usage notes:");
log_print(". Variable parameters are: Number, String, PV, VG, LV, Tag.");
log_print(". Select indicates that a required positional parameter can");
log_print(" be omitted if the --select option is used.");
log_print(". --size Number can be replaced with --extents NumberExtents.");
log_print(". For required options listed in parentheses, e.g. (--A, --B),");
log_print(" any one is required, after which the others are optional.");
log_print(". The _new suffix indicates the VG or LV must not yet exist.");
log_print(". LV followed by _<type> indicates that an LV of the given type");
log_print(" is required. (raid represents any raid<N> type.)");
log_print(". See man pages for short option equivalents of long option names,");
log_print(" and for more detailed descriptions of variable parameters.");
}
return 1;
@@ -1201,7 +1430,7 @@ static void _add_getopt_arg(int arg_enum, char **optstrp, struct option **longop
if (a->short_arg) {
*(*optstrp)++ = a->short_arg;
if (a->fn)
if (a->val_enum)
*(*optstrp)++ = ':';
}
#ifdef HAVE_GETOPTLONG
@@ -1209,7 +1438,7 @@ static void _add_getopt_arg(int arg_enum, char **optstrp, struct option **longop
if (*(a->long_arg + 2)) {
(*longoptsp)->name = a->long_arg + 2;
(*longoptsp)->has_arg = a->fn ? 1 : 0;
(*longoptsp)->has_arg = a->val_enum ? 1 : 0;
(*longoptsp)->flag = NULL;
/*
@@ -1234,35 +1463,63 @@ static void _add_getopt_arg(int arg_enum, char **optstrp, struct option **longop
#endif
}
static int _find_arg(int goval)
/*
* getopt_long() has returned goval which indicates which option it's found.
* We need to translate that goval to an enum value from the args array.
*
* For options with both long and short forms, goval is the character value
* of the short option. For options with only a long form, goval is the
* corresponding enum value plus 128.
*
* The trick with character values is that different long options share the
* same single-letter short form. So, we have to translate goval to an
* enum using only the set of valid options for the given command. And,
* a command name is not allowed to use two different long options that
* have the same single-letter short form.
*/
static int _find_arg(const char *cmd_name, int goval)
{
struct command_name *cname;
int arg_enum;
int i;
for (i = 0; i < ARG_COUNT; i++) {
if (!(cname = _find_command_name(cmd_name)))
return -1;
for (i = 0; i < cname->num_args; i++) {
arg_enum = cname->valid_args[i];
/* assert arg_enum == _cmdline.arg_props[arg_enum].arg_enum */
/* the value returned by getopt matches the ascii value of single letter option */
if (_cmdline.arg_props[i].short_arg && (goval == _cmdline.arg_props[i].short_arg))
return _cmdline.arg_props[i].enum_val;
if (_cmdline.arg_props[arg_enum].short_arg && (goval == _cmdline.arg_props[arg_enum].short_arg))
return arg_enum;
/* the value returned by getopt matches the enum value plus 128 */
if (!_cmdline.arg_props[i].short_arg && (goval == _cmdline.arg_props[i].enum_val + 128))
return _cmdline.arg_props[i].enum_val;
if (!_cmdline.arg_props[arg_enum].short_arg && (goval == (arg_enum + 128)))
return arg_enum;
}
return -1;
}
static int _process_command_line(struct cmd_context *cmd, int *argc,
char ***argv)
static int _process_command_line(struct cmd_context *cmd, const char *cmd_name,
int *argc, char ***argv)
{
char str[((ARG_COUNT + 1) * 2) + 1], *ptr = str;
struct option opts[ARG_COUNT + 1], *o = opts;
struct arg_props *a;
struct arg_values *av;
struct arg_value_group_list *current_group = NULL;
struct command_name *cname;
int arg_enum; /* e.g. foo_ARG */
int goval; /* the number returned from getopt_long identifying what it found */
int i;
if (!(cname = _find_command_name(cmd_name)))
return_0;
if (!(cmd->opt_arg_values = dm_pool_zalloc(cmd->mem, sizeof(*cmd->opt_arg_values) * ARG_COUNT))) {
log_fatal("Unable to allocate memory for command line arguments.");
return 0;
@@ -1273,13 +1530,12 @@ static int _process_command_line(struct cmd_context *cmd, int *argc,
* array (opts) to pass to the getopt_long() function. IOW we generate
* the arguments to pass to getopt_long() from the args.h/arg_props data.
*/
for (i = 0; i < ARG_COUNT; i++)
_add_getopt_arg(_cmdline.arg_props[i].enum_val, &ptr, &o);
for (i = 0; i < cname->num_args; i++)
_add_getopt_arg(cname->valid_args[i], &ptr, &o);
*ptr = '\0';
memset(o, 0, sizeof(*o));
/* initialise getopt_long & scan for command line switches */
optarg = 0;
optind = OPTIND_INIT;
while ((goval = GETOPTLONG_FN(*argc, *argv, str, opts, NULL)) >= 0) {
@@ -1289,9 +1545,9 @@ static int _process_command_line(struct cmd_context *cmd, int *argc,
/*
* translate the option value used by getopt into the enum
* value (e.g. foo_ARG) from the args array....
* value (e.g. foo_ARG) from the args array.
*/
if ((arg_enum = _find_arg(goval)) < 0) {
if ((arg_enum = _find_arg(cmd_name, goval)) < 0) {
log_fatal("Unrecognised option.");
return 0;
}
@@ -1333,7 +1589,7 @@ static int _process_command_line(struct cmd_context *cmd, int *argc,
return 0;
}
if (a->fn) {
if (a->val_enum) {
if (!optarg) {
log_error("Option requires argument.");
return 0;
@@ -1341,7 +1597,7 @@ static int _process_command_line(struct cmd_context *cmd, int *argc,
av->value = optarg;
if (!a->fn(cmd, av)) {
if (!_val_props[a->val_enum].fn(cmd, av)) {
log_error("Invalid argument for %s: %s", a->long_arg, optarg);
return 0;
}
@@ -1425,15 +1681,10 @@ int version(struct cmd_context *cmd __attribute__((unused)),
return ECMD_PROCESSED;
}
static int _get_settings(struct cmd_context *cmd)
static void _get_output_settings(struct cmd_context *cmd)
{
const char *activation_mode;
cmd->current_settings = cmd->default_settings;
if (arg_is_set(cmd, debug_ARG))
cmd->current_settings.debug = _LOG_FATAL +
(arg_count(cmd, debug_ARG) - 1);
cmd->current_settings.debug = _LOG_FATAL + (arg_count(cmd, debug_ARG) - 1);
if (arg_is_set(cmd, verbose_ARG))
cmd->current_settings.verbose = arg_count(cmd, verbose_ARG);
@@ -1443,6 +1694,19 @@ static int _get_settings(struct cmd_context *cmd)
cmd->current_settings.verbose = 0;
cmd->current_settings.silent = (arg_count(cmd, quiet_ARG) > 1) ? 1 : 0;
}
}
static void _apply_output_settings(struct cmd_context *cmd)
{
init_debug(cmd->current_settings.debug);
init_debug_classes_logged(cmd->default_settings.debug_classes);
init_verbose(cmd->current_settings.verbose + VERBOSE_BASE_LEVEL);
init_silent(cmd->current_settings.silent);
}
static int _get_settings(struct cmd_context *cmd)
{
const char *activation_mode;
if (arg_is_set(cmd, test_ARG))
cmd->current_settings.test = arg_is_set(cmd, test_ARG);
@@ -1572,7 +1836,7 @@ static int _process_common_commands(struct cmd_context *cmd)
_usage(cmd->command->name, arg_count(cmd, help_ARG));
if (arg_count(cmd, help_ARG) < 2)
log_print("(Use --help --help to include optional parameters.)");
log_print("(Use --help --help for usage notes.)");
return ECMD_PROCESSED;
}
@@ -1617,10 +1881,6 @@ int help(struct cmd_context *cmd __attribute__((unused)), int argc, char **argv)
static void _apply_settings(struct cmd_context *cmd)
{
init_debug(cmd->current_settings.debug);
init_debug_classes_logged(cmd->default_settings.debug_classes);
init_verbose(cmd->current_settings.verbose + VERBOSE_BASE_LEVEL);
init_silent(cmd->current_settings.silent);
init_test(cmd->current_settings.test);
init_full_scan_done(0);
init_mirror_in_sync(0);
@@ -1935,17 +2195,27 @@ int lvm_run_command(struct cmd_context *cmd, int argc, char **argv)
*arg_new = '\0';
}
/* The cmd_line string is only used for logging, not processing. */
if (!(cmd->cmd_line = _copy_command_line(cmd, argc, argv)))
return_ECMD_FAILED;
log_debug("Parsing: %s", cmd->cmd_line);
if (!_process_command_line(cmd, &argc, &argv)) {
if (!_process_command_line(cmd, cmd_name, &argc, &argv)) {
log_error("Error during parsing of command line.");
return EINVALID_CMD_LINE;
}
if (!(cmd->command = _find_command(cmd, cmd_name)))
/*
* log_debug() can be enabled now that we know the settings
* from the command. Previous calls to log_debug() will
* do nothing.
*/
cmd->current_settings = cmd->default_settings;
_get_output_settings(cmd);
_apply_output_settings(cmd);
log_debug("Parsing: %s", cmd->cmd_line);
if (!(cmd->command = _find_command(cmd, cmd_name, &argc, argv)))
return ENO_SUCH_CMD;
set_cmd_name(cmd_name);
@@ -2574,7 +2844,7 @@ int lvm2_main(int argc, char **argv)
if (!(cmd = init_lvm(0, 0)))
return -1;
cmd->pos_arg_values = argv;
cmd->argv = argv;
lvm_register_commands();

View File

@@ -105,7 +105,7 @@ int become_daemon(struct cmd_context *cmd, int skip_lvm)
init_verbose(VERBOSE_BASE_LEVEL);
#endif /* DEBUG_CHILD */
strncpy(*cmd->pos_arg_values, "(lvm2)", strlen(*cmd->pos_arg_values));
strncpy(*cmd->argv, "(lvm2)", strlen(*cmd->argv));
lvmetad_disconnect();

View File

@@ -50,7 +50,14 @@
#define CMD_LEN 256
#define MAX_ARGS 64
/* define the enums for the command line switches */
/* define the enums for the values accepted by command line --options */
enum {
#define val(a, b, c, d) a ,
#include "vals.h"
#undef val
};
/* define the enums for the command line --options */
enum {
#define arg(a, b, c, d, e, f) a ,
#include "args.h"
@@ -79,14 +86,13 @@ struct arg_values {
/* void *ptr; // Currently not used. */
};
/* a global table of possible arguments */
/* a global table of possible --option's */
struct arg_props {
int enum_val;
int arg_enum; /* foo_ARG from args.h */
const char short_arg;
char _padding[7];
const char *long_arg;
int (*fn) (struct cmd_context *cmd, struct arg_values *av);
int val_enum; /* foo_VAL from vals.h */
uint32_t flags;
uint32_t prio;
};
@@ -97,6 +103,14 @@ struct arg_value_group_list {
uint32_t prio;
};
/* a global table of possible --option values */
struct val_props {
int val_enum; /* foo_VAL from vals.h */
int (*fn) (struct cmd_context *cmd, struct arg_values *av);
const char *name;
const char *usage;
};
#define CACHE_VGMETADATA 0x00000001
#define PERMITTED_READ_ONLY 0x00000002
/* Process all VGs if none specified on the command line. */

135
tools/vals.h Normal file
View File

@@ -0,0 +1,135 @@
/*
* Define value types which describe values accepted
* by the --option's in args.h, and can also describe
* the values accepted as positional args.
*
* Previously, accepted values were only "described"
* by identifying the parsing function to use.
*
* Some standard val types are used by many options,
* e.g. many options (aa_ARG, bb_ARG, cc_ARG) all
* accept a number_VAL.
*
* Other special val types are used by only one option,
* e.g. only mirrorlog_ARG accepts a mirrorlog_VAL.
* This typically means that there are some specific
* words that are recognized after the option.
*
* Some options currently take a standard val type,
* (esp string_VAL), but they could be given their
* own custom val type. The advantage of using a
* custom val type is the possibility of validating
* the value when parsing it with a custom parsing
* function, and the possibility of displaying the
* actual accepted values in the command usage.
* Without a custom val type, the code must do ad hoc
* validation of the string values, and the usage
* output for the option will only say "String"
* rather than giving the accepted string values.
* Even without a custom parsing function, there is
* reason to define a custom x_VAL enum so that a
* more descriptive usage string can be specified
* as opposed to just "String".
*
* Most of the val types defined here are used after
* --option's, and are referenced in foo_ARG entries
* in args.h. But, some val types are only used to
* represent positional values in command definitions,
* e.g. vg_VAL.
*
* val(a, b, c, d)
*
* a: foo_VAL enums
* b: the function to parse and set the value
* c: the name used to reference this value in command defs
* d: what to display in usage output for this value
*
* command defintions will use --option NAME, where NAME
* is shown in val() field c. NAME will be translated to
* foo_VAL enum in field a, which is used in commands[]
* structs.
*
* option definitions (arg.h) will reference foo_VAL enum
* in field a.
*
* FIXME: for specialized val types, the set of recognized
* words is not defined or stored in a consistent way,
* but is just whatever the parsing function happens to look
* for, so adding a new accepted value for the val type is
* often just making the parsing function recognize a new
* word. This new word should then also be added to the
* usage string for the val type here. It would be nice
* if the accepted values could be defined in a more
* consistent way, perhaps in struct val_props.
*
* The usage text for an option is not always the full
* set of words accepted for an option, but may be a
* subset. i.e. an outdated word that no longer does
* anything may not be shown, but may still be recognized
* and ignored, or an option that shouldn't be used in
* general isn't shown to avoid suggesting it.
* e.g. for --activate we show the most common "y|n|ay"
* without showing the lvmlockd variations "ey|sy" which
* are not applicable in general.
*
* FIXME: are there some specialized or irrelevant
* options included in the usage text below that should
* be removed? Should "lvm1" be removed?
*
* For Number args that take optional units, a full usage
* could be "Number[bBsSkKmMgGtTpPeE]" (with implied |),
* but repeating this full specification produces cluttered
* output, and doesn't indicate which unit is the default.
* "Number[units]" would be cleaner, as would a subset of
* common units, e.g. "Number[kmg...]", but neither helps
* with default. "Number[k|unit]" and "Number[m|unit]" show
* the default, and "unit" indicates that other units
* are possible without listing them all. This also
* suggests using the preferred lower case letters, because
* --size and other option args treat upper/lower letters
* the same, all as 1024 SI base. For this reason, we
* should avoid suggesting the upper case letters.
*/
val(none_VAL, NULL, "None", "") /* unused, for enum value 0 */
val(conststr_VAL, NULL, "ConstString", "") /* used only for command defs */
val(constnum_VAL, NULL, "ConstNumber", "") /* used only for command defs */
val(bool_VAL, yes_no_arg, "Bool", "y|n")
val(number_VAL, int_arg, "Number", NULL)
val(string_VAL, string_arg, "String", NULL)
val(vg_VAL, string_arg, "VG", NULL)
val(lv_VAL, string_arg, "LV", NULL)
val(pv_VAL, string_arg, "PV", NULL)
val(tag_VAL, tag_arg, "Tag", NULL)
val(select_VAL, NULL, "Select", NULL) /* used only for command defs */
val(activationmode_VAL, string_arg, "ActivationMode", "partial|degraded|complete")
val(activation_VAL, activation_arg, "Active", "y|n|ay")
val(cachemode_VAL, cachemode_arg, "CacheMode", "writethrough|writeback")
val(discards_VAL, discards_arg, "Discards", "passdown|nopassdown|ignore")
val(mirrorlog_VAL, mirrorlog_arg, "MirrorLog", "core|disk")
val(sizekb_VAL, size_kb_arg, "SizeKB", "Number[k|unit]")
val(sizemb_VAL, size_mb_arg, "SizeMB", "Number[m|unit]")
val(numsigned_VAL, int_arg_with_sign, "SNumber", "[+|-]Number")
val(numsignedper_VAL, int_arg_with_sign_and_percent, "SNumberP", "[+|-]Number[%{VG|PVS|FREE}]")
val(permission_VAL, permission_arg, "Permission", "rw|r")
val(metadatatype_VAL, metadatatype_arg, "MetadataType", "lvm2|lvm1")
val(units_VAL, string_arg, "Units", "hHbBsSkKmMgGtTpPeE")
val(segtype_VAL, segtype_arg, "SegType", "linear|striped|snapshot|mirror|raid*|thin|cache|thin-pool|cache-pool")
val(alloc_VAL, alloc_arg, "Alloc", "contiguous|cling|cling_by_tags|normal|anywhere|inherit")
val(locktype_VAL, locktype_arg, "LockType", "sanlock|dlm|none")
val(readahead_VAL, readahead_arg, "Readahead", "auto|none|NumberSectors")
val(metadatacopies_VAL, metadatacopies_arg, "MetadataCopies", "all|unmanaged|Number")
/* this should always be last */
val(VAL_COUNT, NULL, NULL, NULL)
/*
* I suspect many of the following are good candidates for a custom VAL enum
* for the benefit of custom parsing, or custom usage, or both:
*
* configreport_ARG, configtype_ARG, polloperation_ARG, raidrebuild_ARG,
* raidsyncaction_ARG, raidwritemostly_ARG, reportformat_ARG, syncaction_ARG,
* cachepolicy_ARG, cachesettings_ARG, writemostly_ARG
*/