mirror of
git://sourceware.org/git/lvm2.git
synced 2024-12-21 13:34:40 +03:00
dmsetup: refactor getopt_long usage
Shuffle code to avoid using static variable to pass parsed option. Code is now easier to follow and also number of coverity reports will go away. There should be no functional change.
This commit is contained in:
parent
1c2dff2655
commit
8c4b8c6e27
@ -152,85 +152,86 @@ static const int _num_base_commands = DM_ARRAY_SIZE(_base_commands);
|
|||||||
* We have only very simple switches ATM.
|
* We have only very simple switches ATM.
|
||||||
*/
|
*/
|
||||||
enum {
|
enum {
|
||||||
READ_ONLY = 0,
|
GID_ARG = 'G',
|
||||||
ADD_NODE_ON_CREATE_ARG,
|
MODE_ARG = 'M',
|
||||||
|
SORT_ARG = 'O',
|
||||||
|
SELECT_ARG = 'S',
|
||||||
|
UID_ARG = 'U',
|
||||||
|
COLS_ARG = 'c',
|
||||||
|
FORCE_ARG = 'f',
|
||||||
|
HELP_ARG = 'h',
|
||||||
|
MAJOR_ARG = 'j',
|
||||||
|
MINOR_ARG = 'm',
|
||||||
|
NOTABLE_ARG = 'n',
|
||||||
|
OPTIONS_ARG = 'o',
|
||||||
|
READ_ONLY = 'r',
|
||||||
|
UUID_ARG = 'u',
|
||||||
|
VERBOSE_ARG = 'v',
|
||||||
|
YES_ARG = 'y',
|
||||||
|
|
||||||
|
ADD_NODE_ON_CREATE_ARG = 128,
|
||||||
ADD_NODE_ON_RESUME_ARG,
|
ADD_NODE_ON_RESUME_ARG,
|
||||||
ALIAS_ARG,
|
ALIAS_ARG,
|
||||||
ALL_DEVICES_ARG,
|
ALL_DEVICES_ARG,
|
||||||
ALL_PROGRAMS_ARG,
|
ALL_PROGRAMS_ARG,
|
||||||
ALL_REGIONS_ARG,
|
ALL_REGIONS_ARG,
|
||||||
AREA_ARG,
|
|
||||||
AREAS_ARG,
|
AREAS_ARG,
|
||||||
|
AREA_ARG,
|
||||||
AREA_SIZE_ARG,
|
AREA_SIZE_ARG,
|
||||||
CONCISE_ARG,
|
|
||||||
BOUNDS_ARG,
|
BOUNDS_ARG,
|
||||||
CHECKS_ARG,
|
CHECKS_ARG,
|
||||||
CLEAR_ARG,
|
CLEAR_ARG,
|
||||||
COLS_ARG,
|
CONCISE_ARG,
|
||||||
COUNT_ARG,
|
COUNT_ARG,
|
||||||
DEFERRED_ARG,
|
DEFERRED_ARG,
|
||||||
SELECT_ARG,
|
|
||||||
EXEC_ARG,
|
EXEC_ARG,
|
||||||
FILEMAP_ARG,
|
FILEMAP_ARG,
|
||||||
FOLLOW_ARG,
|
FOLLOW_ARG,
|
||||||
FORCE_ARG,
|
|
||||||
FOREGROUND_ARG,
|
FOREGROUND_ARG,
|
||||||
GID_ARG,
|
|
||||||
GROUP_ARG,
|
GROUP_ARG,
|
||||||
GROUP_ID_ARG,
|
GROUP_ID_ARG,
|
||||||
HEADINGS_ARG,
|
HEADINGS_ARG,
|
||||||
HELP_ARG,
|
|
||||||
HISTOGRAM_ARG,
|
HISTOGRAM_ARG,
|
||||||
INACTIVE_ARG,
|
INACTIVE_ARG,
|
||||||
INTERVAL_ARG,
|
INTERVAL_ARG,
|
||||||
LENGTH_ARG,
|
LENGTH_ARG,
|
||||||
MANGLENAME_ARG,
|
MANGLENAME_ARG,
|
||||||
MAJOR_ARG,
|
|
||||||
REGIONS_ARG,
|
|
||||||
MINOR_ARG,
|
|
||||||
MODE_ARG,
|
|
||||||
NAMEPREFIXES_ARG,
|
NAMEPREFIXES_ARG,
|
||||||
NOFLUSH_ARG,
|
NOFLUSH_ARG,
|
||||||
NOGROUP_ARG,
|
NOGROUP_ARG,
|
||||||
NOHEADINGS_ARG,
|
NOHEADINGS_ARG,
|
||||||
NOLOCKFS_ARG,
|
NOLOCKFS_ARG,
|
||||||
|
NOMONITOR_ARG,
|
||||||
NOOPENCOUNT_ARG,
|
NOOPENCOUNT_ARG,
|
||||||
NOSUFFIX_ARG,
|
NOSUFFIX_ARG,
|
||||||
NOTABLE_ARG,
|
|
||||||
NOTIMESUFFIX_ARG,
|
NOTIMESUFFIX_ARG,
|
||||||
UDEVCOOKIE_ARG,
|
|
||||||
NOMONITOR_ARG,
|
|
||||||
NOUDEVRULES_ARG,
|
NOUDEVRULES_ARG,
|
||||||
NOUDEVSYNC_ARG,
|
NOUDEVSYNC_ARG,
|
||||||
OPTIONS_ARG,
|
|
||||||
PRECISE_ARG,
|
PRECISE_ARG,
|
||||||
PROGRAM_ID_ARG,
|
PROGRAM_ID_ARG,
|
||||||
RAW_ARG,
|
RAW_ARG,
|
||||||
READAHEAD_ARG,
|
READAHEAD_ARG,
|
||||||
|
REGIONS_ARG,
|
||||||
REGION_ARG,
|
REGION_ARG,
|
||||||
REGION_ID_ARG,
|
REGION_ID_ARG,
|
||||||
RELATIVE_ARG,
|
RELATIVE_ARG,
|
||||||
RETRY_ARG,
|
RETRY_ARG,
|
||||||
ROWS_ARG,
|
ROWS_ARG,
|
||||||
|
SEGMENTS_ARG,
|
||||||
SEPARATOR_ARG,
|
SEPARATOR_ARG,
|
||||||
SETUUID_ARG,
|
SETUUID_ARG,
|
||||||
SHOWKEYS_ARG,
|
SHOWKEYS_ARG,
|
||||||
SORT_ARG,
|
|
||||||
START_ARG,
|
START_ARG,
|
||||||
TABLE_ARG,
|
TABLE_ARG,
|
||||||
TARGET_ARG,
|
TARGET_ARG,
|
||||||
SEGMENTS_ARG,
|
|
||||||
TREE_ARG,
|
TREE_ARG,
|
||||||
UID_ARG,
|
UDEVCOOKIE_ARG,
|
||||||
UNBUFFERED_ARG,
|
UNBUFFERED_ARG,
|
||||||
UNITS_ARG,
|
UNITS_ARG,
|
||||||
UNQUOTED_ARG,
|
UNQUOTED_ARG,
|
||||||
USER_DATA_ARG,
|
USER_DATA_ARG,
|
||||||
UUID_ARG,
|
|
||||||
VERBOSE_ARG,
|
|
||||||
VERIFYUDEV_ARG,
|
VERIFYUDEV_ARG,
|
||||||
VERSION_ARG,
|
VERSION_ARG,
|
||||||
YES_ARG,
|
|
||||||
NUM_SWITCHES
|
NUM_SWITCHES
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -6851,90 +6852,89 @@ static int _process_switches(int *argcp, char ***argvp, const char *dev_dir)
|
|||||||
{
|
{
|
||||||
const char *base;
|
const char *base;
|
||||||
char *namebase, *s;
|
char *namebase, *s;
|
||||||
static int ind;
|
|
||||||
int c, r, i;
|
int c, r, i;
|
||||||
|
|
||||||
#ifdef HAVE_GETOPTLONG
|
#ifdef HAVE_GETOPTLONG
|
||||||
static struct option long_options[] = {
|
static struct option long_options[] = {
|
||||||
{"readonly", 0, &ind, READ_ONLY},
|
{"addnodeoncreate", 0, 0, ADD_NODE_ON_CREATE_ARG},
|
||||||
{"alias", 1, &ind, ALIAS_ARG},
|
{"addnodeonresume", 0, 0, ADD_NODE_ON_RESUME_ARG},
|
||||||
{"alldevices", 0, &ind, ALL_DEVICES_ARG},
|
{"alias", 1, 0, ALIAS_ARG},
|
||||||
{"allprograms", 0, &ind, ALL_PROGRAMS_ARG},
|
{"alldevices", 0, 0, ALL_DEVICES_ARG},
|
||||||
{"allregions", 0, &ind, ALL_REGIONS_ARG},
|
{"allprograms", 0, 0, ALL_PROGRAMS_ARG},
|
||||||
{"area", 0, &ind, AREA_ARG},
|
{"allregions", 0, 0, ALL_REGIONS_ARG},
|
||||||
{"areas", 1, &ind, AREAS_ARG},
|
{"area", 0, 0, AREA_ARG},
|
||||||
{"areasize", 1, &ind, AREA_SIZE_ARG},
|
{"areas", 1, 0, AREAS_ARG},
|
||||||
{"bounds", 1, &ind, BOUNDS_ARG},
|
{"areasize", 1, 0, AREA_SIZE_ARG},
|
||||||
{"checks", 0, &ind, CHECKS_ARG},
|
{"bounds", 1, 0, BOUNDS_ARG},
|
||||||
{"clear", 0, &ind, CLEAR_ARG},
|
{"checks", 0, 0, CHECKS_ARG},
|
||||||
{"columns", 0, &ind, COLS_ARG},
|
{"clear", 0, 0, CLEAR_ARG},
|
||||||
{"concise", 0, &ind, CONCISE_ARG},
|
{"columns", 0, 0, COLS_ARG},
|
||||||
{"count", 1, &ind, COUNT_ARG},
|
{"concise", 0, 0, CONCISE_ARG},
|
||||||
{"deferred", 0, &ind, DEFERRED_ARG},
|
{"count", 1, 0, COUNT_ARG},
|
||||||
{"select", 1, &ind, SELECT_ARG},
|
{"deferred", 0, 0, DEFERRED_ARG},
|
||||||
{"exec", 1, &ind, EXEC_ARG},
|
{"exec", 1, 0, EXEC_ARG},
|
||||||
{"filemap", 0, &ind, FILEMAP_ARG},
|
{"filemap", 0, 0, FILEMAP_ARG},
|
||||||
{"follow", 1, &ind, FOLLOW_ARG},
|
{"follow", 1, 0, FOLLOW_ARG},
|
||||||
{"force", 0, &ind, FORCE_ARG},
|
{"force", 0, 0, FORCE_ARG},
|
||||||
{"foreground", 0, &ind, FOREGROUND_ARG},
|
{"foreground", 0, 0, FOREGROUND_ARG},
|
||||||
{"gid", 1, &ind, GID_ARG},
|
{"gid", 1, 0, GID_ARG},
|
||||||
{"group", 0, &ind, GROUP_ARG},
|
{"group", 0, 0, GROUP_ARG},
|
||||||
{"groupid", 1, &ind, GROUP_ID_ARG},
|
{"groupid", 1, 0, GROUP_ID_ARG},
|
||||||
{"headings", 1, &ind, HEADINGS_ARG},
|
{"headings", 1, 0, HEADINGS_ARG},
|
||||||
{"help", 0, &ind, HELP_ARG},
|
{"help", 0, 0, HELP_ARG},
|
||||||
{"histogram", 0, &ind, HISTOGRAM_ARG},
|
{"histogram", 0, 0, HISTOGRAM_ARG},
|
||||||
{"inactive", 0, &ind, INACTIVE_ARG},
|
{"inactive", 0, 0, INACTIVE_ARG},
|
||||||
{"interval", 1, &ind, INTERVAL_ARG},
|
{"interval", 1, 0, INTERVAL_ARG},
|
||||||
{"length", 1, &ind, LENGTH_ARG},
|
{"length", 1, 0, LENGTH_ARG},
|
||||||
{"manglename", 1, &ind, MANGLENAME_ARG},
|
{"major", 1, 0, MAJOR_ARG},
|
||||||
{"major", 1, &ind, MAJOR_ARG},
|
{"manglename", 1, 0, MANGLENAME_ARG},
|
||||||
{"minor", 1, &ind, MINOR_ARG},
|
{"minor", 1, 0, MINOR_ARG},
|
||||||
{"mode", 1, &ind, MODE_ARG},
|
{"mode", 1, 0, MODE_ARG},
|
||||||
{"nameprefixes", 0, &ind, NAMEPREFIXES_ARG},
|
{"nameprefixes", 0, 0, NAMEPREFIXES_ARG},
|
||||||
{"nogroup", 0, &ind, NOGROUP_ARG},
|
{"noflush", 0, 0, NOFLUSH_ARG},
|
||||||
{"noflush", 0, &ind, NOFLUSH_ARG},
|
{"nogroup", 0, 0, NOGROUP_ARG},
|
||||||
{"noheadings", 0, &ind, NOHEADINGS_ARG},
|
{"noheadings", 0, 0, NOHEADINGS_ARG},
|
||||||
{"nolockfs", 0, &ind, NOLOCKFS_ARG},
|
{"nolockfs", 0, 0, NOLOCKFS_ARG},
|
||||||
{"noopencount", 0, &ind, NOOPENCOUNT_ARG},
|
{"nomonitor", 0, 0, NOMONITOR_ARG},
|
||||||
{"nosuffix", 0, &ind, NOSUFFIX_ARG},
|
{"noopencount", 0, 0, NOOPENCOUNT_ARG},
|
||||||
{"notable", 0, &ind, NOTABLE_ARG},
|
{"nosuffix", 0, 0, NOSUFFIX_ARG},
|
||||||
{"notimesuffix", 0, &ind, NOTIMESUFFIX_ARG},
|
{"notable", 0, 0, NOTABLE_ARG},
|
||||||
{"udevcookie", 1, &ind, UDEVCOOKIE_ARG},
|
{"notimesuffix", 0, 0, NOTIMESUFFIX_ARG},
|
||||||
{"nomonitor", 0, &ind, NOMONITOR_ARG},
|
{"noudevrules", 0, 0, NOUDEVRULES_ARG},
|
||||||
{"noudevrules", 0, &ind, NOUDEVRULES_ARG},
|
{"noudevsync", 0, 0, NOUDEVSYNC_ARG},
|
||||||
{"noudevsync", 0, &ind, NOUDEVSYNC_ARG},
|
{"options", 1, 0, OPTIONS_ARG},
|
||||||
{"options", 1, &ind, OPTIONS_ARG},
|
{"precise", 0, 0, PRECISE_ARG},
|
||||||
{"precise", 0, &ind, PRECISE_ARG},
|
{"programid", 1, 0, PROGRAM_ID_ARG},
|
||||||
{"programid", 1, &ind, PROGRAM_ID_ARG},
|
{"raw", 0, 0, RAW_ARG},
|
||||||
{"raw", 0, &ind, RAW_ARG},
|
{"readahead", 1, 0, READAHEAD_ARG},
|
||||||
{"readahead", 1, &ind, READAHEAD_ARG},
|
{"readonly", 0, 0, READ_ONLY},
|
||||||
{"region", 0, &ind, REGION_ARG},
|
{"region", 0, 0, REGION_ARG},
|
||||||
{"regions", 1, &ind, REGIONS_ARG},
|
{"regionid", 1, 0, REGION_ID_ARG},
|
||||||
{"regionid", 1, &ind, REGION_ID_ARG},
|
{"regions", 1, 0, REGIONS_ARG},
|
||||||
{"relative", 0, &ind, RELATIVE_ARG},
|
{"relative", 0, 0, RELATIVE_ARG},
|
||||||
{"retry", 0, &ind, RETRY_ARG},
|
{"retry", 0, 0, RETRY_ARG},
|
||||||
{"rows", 0, &ind, ROWS_ARG},
|
{"rows", 0, 0, ROWS_ARG},
|
||||||
{"segments", 0, &ind, SEGMENTS_ARG},
|
{"segments", 0, 0, SEGMENTS_ARG},
|
||||||
{"separator", 1, &ind, SEPARATOR_ARG},
|
{"select", 1, 0, SELECT_ARG},
|
||||||
{"setuuid", 0, &ind, SETUUID_ARG},
|
{"separator", 1, 0, SEPARATOR_ARG},
|
||||||
{"showkeys", 0, &ind, SHOWKEYS_ARG},
|
{"setuuid", 0, 0, SETUUID_ARG},
|
||||||
{"sort", 1, &ind, SORT_ARG},
|
{"showkeys", 0, 0, SHOWKEYS_ARG},
|
||||||
{"start", 1, &ind, START_ARG},
|
{"sort", 1, 0, SORT_ARG},
|
||||||
{"table", 1, &ind, TABLE_ARG},
|
{"start", 1, 0, START_ARG},
|
||||||
{"target", 1, &ind, TARGET_ARG},
|
{"table", 1, 0, TABLE_ARG},
|
||||||
{"tree", 0, &ind, TREE_ARG},
|
{"target", 1, 0, TARGET_ARG},
|
||||||
{"uid", 1, &ind, UID_ARG},
|
{"tree", 0, 0, TREE_ARG},
|
||||||
{"units", 1, &ind, UNITS_ARG},
|
{"udevcookie", 1, 0, UDEVCOOKIE_ARG},
|
||||||
{"uuid", 1, &ind, UUID_ARG},
|
{"uid", 1, 0, UID_ARG},
|
||||||
{"unbuffered", 0, &ind, UNBUFFERED_ARG},
|
{"unbuffered", 0, 0, UNBUFFERED_ARG},
|
||||||
{"unquoted", 0, &ind, UNQUOTED_ARG},
|
{"units", 1, 0, UNITS_ARG},
|
||||||
{"userdata", 1, &ind, USER_DATA_ARG},
|
{"unquoted", 0, 0, UNQUOTED_ARG},
|
||||||
{"verbose", 1, &ind, VERBOSE_ARG},
|
{"userdata", 1, 0, USER_DATA_ARG},
|
||||||
{"verifyudev", 0, &ind, VERIFYUDEV_ARG},
|
{"uuid", 1, 0, UUID_ARG},
|
||||||
{"version", 0, &ind, VERSION_ARG},
|
{"verbose", 1, 0, VERBOSE_ARG},
|
||||||
{"yes", 0, &ind, YES_ARG},
|
{"verifyudev", 0, 0, VERIFYUDEV_ARG},
|
||||||
{"addnodeonresume", 0, &ind, ADD_NODE_ON_RESUME_ARG},
|
{"version", 0, 0, VERSION_ARG},
|
||||||
{"addnodeoncreate", 0, &ind, ADD_NODE_ON_CREATE_ARG},
|
{"yes", 0, 0, YES_ARG},
|
||||||
{0, 0, 0, 0}
|
{0, 0, 0, 0}
|
||||||
};
|
};
|
||||||
#else
|
#else
|
||||||
@ -7004,171 +7004,204 @@ static int _process_switches(int *argcp, char ***argvp, const char *dev_dir)
|
|||||||
|
|
||||||
optarg = (char*) "";
|
optarg = (char*) "";
|
||||||
optind = OPTIND_INIT;
|
optind = OPTIND_INIT;
|
||||||
while ((ind = -1, c = GETOPTLONG_FN(*argcp, *argvp, "cCfG:hj:m:M:no:O:rS:u:U:vy",
|
while ((c = GETOPTLONG_FN(*argcp, *argvp, "cCfG:hj:m:M:no:O:rS:u:U:vy",
|
||||||
long_options, NULL)) != -1) {
|
long_options, NULL)) != -1) {
|
||||||
if (ind == ALIAS_ARG) {
|
switch (c) {
|
||||||
|
case ALIAS_ARG:
|
||||||
_switches[ALIAS_ARG]++;
|
_switches[ALIAS_ARG]++;
|
||||||
_string_args[ALIAS_ARG] = optarg;
|
_string_args[ALIAS_ARG] = optarg;
|
||||||
}
|
break;
|
||||||
if (ind == ALL_DEVICES_ARG)
|
case ALL_DEVICES_ARG:
|
||||||
_switches[ALL_DEVICES_ARG]++;
|
_switches[ALL_DEVICES_ARG]++;
|
||||||
if (ind == ALL_PROGRAMS_ARG)
|
break;
|
||||||
|
case ALL_PROGRAMS_ARG:
|
||||||
_switches[ALL_PROGRAMS_ARG]++;
|
_switches[ALL_PROGRAMS_ARG]++;
|
||||||
if (ind == ALL_REGIONS_ARG)
|
break;
|
||||||
|
case ALL_REGIONS_ARG:
|
||||||
_switches[ALL_REGIONS_ARG]++;
|
_switches[ALL_REGIONS_ARG]++;
|
||||||
if (ind == AREA_ARG)
|
break;
|
||||||
|
case AREA_ARG:
|
||||||
_switches[AREA_ARG]++;
|
_switches[AREA_ARG]++;
|
||||||
if (ind == AREAS_ARG) {
|
break;
|
||||||
|
case AREAS_ARG:
|
||||||
_switches[AREAS_ARG]++;
|
_switches[AREAS_ARG]++;
|
||||||
_int_args[AREAS_ARG] = atoi(optarg);
|
_int_args[AREAS_ARG] = atoi(optarg);
|
||||||
}
|
break;
|
||||||
if (ind == AREA_SIZE_ARG) {
|
case AREA_SIZE_ARG:
|
||||||
_switches[AREA_SIZE_ARG]++;
|
_switches[AREA_SIZE_ARG]++;
|
||||||
_string_args[AREA_SIZE_ARG] = optarg;
|
_string_args[AREA_SIZE_ARG] = optarg;
|
||||||
}
|
break;
|
||||||
if (ind == USER_DATA_ARG) {
|
case USER_DATA_ARG:
|
||||||
_switches[USER_DATA_ARG]++;
|
_switches[USER_DATA_ARG]++;
|
||||||
_string_args[USER_DATA_ARG] = optarg;
|
_string_args[USER_DATA_ARG] = optarg;
|
||||||
}
|
break;
|
||||||
if (c == ':' || c == '?')
|
case ':':
|
||||||
|
case '?':
|
||||||
return_0;
|
return_0;
|
||||||
if (c == 'h' || ind == HELP_ARG)
|
case HELP_ARG:
|
||||||
_switches[HELP_ARG]++;
|
_switches[HELP_ARG]++;
|
||||||
if (ind == CONCISE_ARG)
|
break;
|
||||||
|
case CONCISE_ARG:
|
||||||
_switches[CONCISE_ARG]++;
|
_switches[CONCISE_ARG]++;
|
||||||
if (ind == BOUNDS_ARG) {
|
break;
|
||||||
|
case BOUNDS_ARG:
|
||||||
_switches[BOUNDS_ARG]++;
|
_switches[BOUNDS_ARG]++;
|
||||||
_string_args[BOUNDS_ARG] = optarg;
|
_string_args[BOUNDS_ARG] = optarg;
|
||||||
}
|
break;
|
||||||
if (ind == CLEAR_ARG)
|
case CLEAR_ARG:
|
||||||
_switches[CLEAR_ARG]++;
|
_switches[CLEAR_ARG]++;
|
||||||
if (c == 'c' || c == 'C' || ind == COLS_ARG)
|
break;
|
||||||
|
case 'C':
|
||||||
|
case COLS_ARG:
|
||||||
_switches[COLS_ARG]++;
|
_switches[COLS_ARG]++;
|
||||||
if (ind == FILEMAP_ARG)
|
break;
|
||||||
|
case FILEMAP_ARG:
|
||||||
_switches[FILEMAP_ARG]++;
|
_switches[FILEMAP_ARG]++;
|
||||||
if (ind == FOLLOW_ARG) {
|
break;
|
||||||
|
case FOLLOW_ARG:
|
||||||
_switches[FOLLOW_ARG]++;
|
_switches[FOLLOW_ARG]++;
|
||||||
_string_args[FOLLOW_ARG] = optarg;
|
_string_args[FOLLOW_ARG] = optarg;
|
||||||
}
|
break;
|
||||||
if (c == 'f' || ind == FORCE_ARG)
|
case FORCE_ARG:
|
||||||
_switches[FORCE_ARG]++;
|
_switches[FORCE_ARG]++;
|
||||||
if (ind == FOREGROUND_ARG)
|
break;
|
||||||
|
case FOREGROUND_ARG:
|
||||||
_switches[FOREGROUND_ARG]++;
|
_switches[FOREGROUND_ARG]++;
|
||||||
if (c == 'r' || ind == READ_ONLY)
|
break;
|
||||||
|
case READ_ONLY:
|
||||||
_switches[READ_ONLY]++;
|
_switches[READ_ONLY]++;
|
||||||
if (ind == HISTOGRAM_ARG)
|
break;
|
||||||
|
case HISTOGRAM_ARG:
|
||||||
_switches[HISTOGRAM_ARG]++;
|
_switches[HISTOGRAM_ARG]++;
|
||||||
if (ind == LENGTH_ARG) {
|
break;
|
||||||
|
case LENGTH_ARG:
|
||||||
_switches[LENGTH_ARG]++;
|
_switches[LENGTH_ARG]++;
|
||||||
_string_args[LENGTH_ARG] = optarg;
|
_string_args[LENGTH_ARG] = optarg;
|
||||||
}
|
break;
|
||||||
if (c == 'j' || ind == MAJOR_ARG) {
|
case MAJOR_ARG:
|
||||||
_switches[MAJOR_ARG]++;
|
_switches[MAJOR_ARG]++;
|
||||||
_int_args[MAJOR_ARG] = atoi(optarg);
|
_int_args[MAJOR_ARG] = atoi(optarg);
|
||||||
}
|
break;
|
||||||
if (ind == REGIONS_ARG) {
|
case REGIONS_ARG:
|
||||||
_switches[REGIONS_ARG]++;
|
_switches[REGIONS_ARG]++;
|
||||||
_string_args[REGIONS_ARG] = optarg;
|
_string_args[REGIONS_ARG] = optarg;
|
||||||
}
|
break;
|
||||||
if (c == 'm' || ind == MINOR_ARG) {
|
case MINOR_ARG:
|
||||||
_switches[MINOR_ARG]++;
|
_switches[MINOR_ARG]++;
|
||||||
_int_args[MINOR_ARG] = atoi(optarg);
|
_int_args[MINOR_ARG] = atoi(optarg);
|
||||||
}
|
break;
|
||||||
if (ind == NOSUFFIX_ARG)
|
case NOSUFFIX_ARG:
|
||||||
_switches[NOSUFFIX_ARG]++;
|
_switches[NOSUFFIX_ARG]++;
|
||||||
if (c == 'n' || ind == NOTABLE_ARG)
|
break;
|
||||||
|
case NOTABLE_ARG:
|
||||||
_switches[NOTABLE_ARG]++;
|
_switches[NOTABLE_ARG]++;
|
||||||
if (ind == NOTIMESUFFIX_ARG)
|
break;
|
||||||
|
case NOTIMESUFFIX_ARG:
|
||||||
_switches[NOTIMESUFFIX_ARG]++;
|
_switches[NOTIMESUFFIX_ARG]++;
|
||||||
if (c == 'o' || ind == OPTIONS_ARG) {
|
break;
|
||||||
|
case OPTIONS_ARG:
|
||||||
_switches[OPTIONS_ARG]++;
|
_switches[OPTIONS_ARG]++;
|
||||||
_string_args[OPTIONS_ARG] = optarg;
|
_string_args[OPTIONS_ARG] = optarg;
|
||||||
}
|
break;
|
||||||
if (ind == PROGRAM_ID_ARG) {
|
case PROGRAM_ID_ARG:
|
||||||
_switches[PROGRAM_ID_ARG]++;
|
_switches[PROGRAM_ID_ARG]++;
|
||||||
_string_args[PROGRAM_ID_ARG] = optarg;
|
_string_args[PROGRAM_ID_ARG] = optarg;
|
||||||
}
|
break;
|
||||||
if (ind == PRECISE_ARG)
|
case PRECISE_ARG:
|
||||||
_switches[PRECISE_ARG]++;
|
_switches[PRECISE_ARG]++;
|
||||||
if (ind == RAW_ARG)
|
break;
|
||||||
|
case RAW_ARG:
|
||||||
_switches[RAW_ARG]++;
|
_switches[RAW_ARG]++;
|
||||||
if (ind == REGION_ARG)
|
break;
|
||||||
|
case REGION_ARG:
|
||||||
_switches[REGION_ARG]++;
|
_switches[REGION_ARG]++;
|
||||||
if (ind == REGION_ID_ARG) {
|
break;
|
||||||
|
case REGION_ID_ARG:
|
||||||
_switches[REGION_ID_ARG]++;
|
_switches[REGION_ID_ARG]++;
|
||||||
_int_args[REGION_ID_ARG] = atoi(optarg);
|
_int_args[REGION_ID_ARG] = atoi(optarg);
|
||||||
}
|
break;
|
||||||
if (ind == RELATIVE_ARG)
|
case RELATIVE_ARG:
|
||||||
_switches[RELATIVE_ARG]++;
|
_switches[RELATIVE_ARG]++;
|
||||||
if (ind == SEPARATOR_ARG) {
|
break;
|
||||||
|
case SEPARATOR_ARG:
|
||||||
_switches[SEPARATOR_ARG]++;
|
_switches[SEPARATOR_ARG]++;
|
||||||
_string_args[SEPARATOR_ARG] = optarg;
|
_string_args[SEPARATOR_ARG] = optarg;
|
||||||
}
|
break;
|
||||||
if (ind == UNITS_ARG) {
|
case UNITS_ARG:
|
||||||
_switches[UNITS_ARG]++;
|
_switches[UNITS_ARG]++;
|
||||||
_string_args[UNITS_ARG] = optarg;
|
_string_args[UNITS_ARG] = optarg;
|
||||||
}
|
break;
|
||||||
if (c == 'O' || ind == SORT_ARG) {
|
case SORT_ARG:
|
||||||
_switches[SORT_ARG]++;
|
_switches[SORT_ARG]++;
|
||||||
_string_args[SORT_ARG] = optarg;
|
_string_args[SORT_ARG] = optarg;
|
||||||
}
|
break;
|
||||||
if (c == 'S' || ind == SELECT_ARG) {
|
case SELECT_ARG:
|
||||||
_switches[SELECT_ARG]++;
|
_switches[SELECT_ARG]++;
|
||||||
_string_args[SELECT_ARG] = optarg;
|
_string_args[SELECT_ARG] = optarg;
|
||||||
}
|
break;
|
||||||
if (ind == START_ARG) {
|
case START_ARG:
|
||||||
_switches[START_ARG]++;
|
_switches[START_ARG]++;
|
||||||
_string_args[START_ARG] = optarg;
|
_string_args[START_ARG] = optarg;
|
||||||
}
|
break;
|
||||||
if (c == 'v' || ind == VERBOSE_ARG)
|
case VERBOSE_ARG:
|
||||||
_switches[VERBOSE_ARG]++;
|
_switches[VERBOSE_ARG]++;
|
||||||
if (c == 'u' || ind == UUID_ARG) {
|
break;
|
||||||
|
case UUID_ARG:
|
||||||
_switches[UUID_ARG]++;
|
_switches[UUID_ARG]++;
|
||||||
_uuid = optarg;
|
_uuid = optarg;
|
||||||
}
|
break;
|
||||||
if (c == 'y' || ind == YES_ARG)
|
case YES_ARG:
|
||||||
_switches[YES_ARG]++;
|
_switches[YES_ARG]++;
|
||||||
if (ind == ADD_NODE_ON_RESUME_ARG)
|
break;
|
||||||
|
case ADD_NODE_ON_RESUME_ARG:
|
||||||
_switches[ADD_NODE_ON_RESUME_ARG]++;
|
_switches[ADD_NODE_ON_RESUME_ARG]++;
|
||||||
if (ind == ADD_NODE_ON_CREATE_ARG)
|
break;
|
||||||
|
case ADD_NODE_ON_CREATE_ARG:
|
||||||
_switches[ADD_NODE_ON_CREATE_ARG]++;
|
_switches[ADD_NODE_ON_CREATE_ARG]++;
|
||||||
if (ind == CHECKS_ARG)
|
break;
|
||||||
|
case CHECKS_ARG:
|
||||||
_switches[CHECKS_ARG]++;
|
_switches[CHECKS_ARG]++;
|
||||||
if (ind == COUNT_ARG) {
|
break;
|
||||||
|
case COUNT_ARG:
|
||||||
_switches[COUNT_ARG]++;
|
_switches[COUNT_ARG]++;
|
||||||
_int_args[COUNT_ARG] = atoi(optarg);
|
_int_args[COUNT_ARG] = atoi(optarg);
|
||||||
if (_int_args[COUNT_ARG] < 0) {
|
if (_int_args[COUNT_ARG] < 0) {
|
||||||
log_error("Count must be zero or greater.");
|
log_error("Count must be zero or greater.");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
break;
|
||||||
if (ind == UDEVCOOKIE_ARG) {
|
case UDEVCOOKIE_ARG:
|
||||||
_switches[UDEVCOOKIE_ARG]++;
|
_switches[UDEVCOOKIE_ARG]++;
|
||||||
_udev_cookie = _get_cookie_value(optarg);
|
_udev_cookie = _get_cookie_value(optarg);
|
||||||
}
|
break;
|
||||||
if (ind == NOMONITOR_ARG)
|
case NOMONITOR_ARG:
|
||||||
_switches[NOMONITOR_ARG]++;
|
_switches[NOMONITOR_ARG]++;
|
||||||
if (ind == NOUDEVRULES_ARG)
|
break;
|
||||||
|
case NOUDEVRULES_ARG:
|
||||||
_switches[NOUDEVRULES_ARG]++;
|
_switches[NOUDEVRULES_ARG]++;
|
||||||
if (ind == NOUDEVSYNC_ARG)
|
break;
|
||||||
|
case NOUDEVSYNC_ARG:
|
||||||
_switches[NOUDEVSYNC_ARG]++;
|
_switches[NOUDEVSYNC_ARG]++;
|
||||||
if (ind == VERIFYUDEV_ARG)
|
break;
|
||||||
|
case VERIFYUDEV_ARG:
|
||||||
_switches[VERIFYUDEV_ARG]++;
|
_switches[VERIFYUDEV_ARG]++;
|
||||||
if (c == 'G' || ind == GID_ARG) {
|
break;
|
||||||
|
case GID_ARG:
|
||||||
_switches[GID_ARG]++;
|
_switches[GID_ARG]++;
|
||||||
_int_args[GID_ARG] = atoi(optarg);
|
_int_args[GID_ARG] = atoi(optarg);
|
||||||
}
|
break;
|
||||||
if (ind == GROUP_ARG)
|
case GROUP_ARG:
|
||||||
_switches[GROUP_ARG]++;
|
_switches[GROUP_ARG]++;
|
||||||
if (ind == GROUP_ID_ARG) {
|
break;
|
||||||
|
case GROUP_ID_ARG:
|
||||||
_switches[GROUP_ID_ARG]++;
|
_switches[GROUP_ID_ARG]++;
|
||||||
_int_args[GROUP_ID_ARG] = atoi(optarg);
|
_int_args[GROUP_ID_ARG] = atoi(optarg);
|
||||||
}
|
break;
|
||||||
if (c == 'U' || ind == UID_ARG) {
|
case UID_ARG:
|
||||||
_switches[UID_ARG]++;
|
_switches[UID_ARG]++;
|
||||||
_int_args[UID_ARG] = atoi(optarg);
|
_int_args[UID_ARG] = atoi(optarg);
|
||||||
}
|
break;
|
||||||
if (c == 'M' || ind == MODE_ARG) {
|
case MODE_ARG:
|
||||||
_switches[MODE_ARG]++;
|
_switches[MODE_ARG]++;
|
||||||
/* FIXME Accept modes as per chmod */
|
/* FIXME Accept modes as per chmod */
|
||||||
errno = 0;
|
errno = 0;
|
||||||
@ -7178,14 +7211,15 @@ static int _process_switches(int *argcp, char ***argvp, const char *dev_dir)
|
|||||||
optarg, errno ? strerror(errno) : "");
|
optarg, errno ? strerror(errno) : "");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
break;
|
||||||
if (ind == DEFERRED_ARG)
|
case DEFERRED_ARG:
|
||||||
_switches[DEFERRED_ARG]++;
|
_switches[DEFERRED_ARG]++;
|
||||||
if (ind == EXEC_ARG) {
|
break;
|
||||||
|
case EXEC_ARG:
|
||||||
_switches[EXEC_ARG]++;
|
_switches[EXEC_ARG]++;
|
||||||
_command_to_exec = optarg;
|
_command_to_exec = optarg;
|
||||||
}
|
break;
|
||||||
if (ind == HEADINGS_ARG) {
|
case HEADINGS_ARG:
|
||||||
_switches[HEADINGS_ARG]++;
|
_switches[HEADINGS_ARG]++;
|
||||||
if (!strcasecmp(optarg, "none") || !strcmp(optarg, "0"))
|
if (!strcasecmp(optarg, "none") || !strcmp(optarg, "0"))
|
||||||
_int_args[HEADINGS_ARG] = 0;
|
_int_args[HEADINGS_ARG] = 0;
|
||||||
@ -7197,24 +7231,26 @@ static int _process_switches(int *argcp, char ***argvp, const char *dev_dir)
|
|||||||
log_error("Unknown headings type.");
|
log_error("Unknown headings type.");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
break;
|
||||||
if (ind == TARGET_ARG) {
|
case TARGET_ARG:
|
||||||
_switches[TARGET_ARG]++;
|
_switches[TARGET_ARG]++;
|
||||||
_target = optarg;
|
_target = optarg;
|
||||||
}
|
break;
|
||||||
if (ind == SEGMENTS_ARG)
|
case SEGMENTS_ARG:
|
||||||
_switches[SEGMENTS_ARG]++;
|
_switches[SEGMENTS_ARG]++;
|
||||||
if (ind == INACTIVE_ARG)
|
break;
|
||||||
|
case INACTIVE_ARG:
|
||||||
_switches[INACTIVE_ARG]++;
|
_switches[INACTIVE_ARG]++;
|
||||||
if (ind == INTERVAL_ARG) {
|
break;
|
||||||
|
case INTERVAL_ARG:
|
||||||
_switches[INTERVAL_ARG]++;
|
_switches[INTERVAL_ARG]++;
|
||||||
_int_args[INTERVAL_ARG] = atoi(optarg);
|
_int_args[INTERVAL_ARG] = atoi(optarg);
|
||||||
if (_int_args[INTERVAL_ARG] <= 0) {
|
if (_int_args[INTERVAL_ARG] <= 0) {
|
||||||
log_error("Interval must be a positive integer.");
|
log_error("Interval must be a positive integer.");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
break;
|
||||||
if (ind == MANGLENAME_ARG) {
|
case MANGLENAME_ARG:
|
||||||
_switches[MANGLENAME_ARG]++;
|
_switches[MANGLENAME_ARG]++;
|
||||||
if (!strcasecmp(optarg, "none"))
|
if (!strcasecmp(optarg, "none"))
|
||||||
_int_args[MANGLENAME_ARG] = DM_STRING_MANGLING_NONE;
|
_int_args[MANGLENAME_ARG] = DM_STRING_MANGLING_NONE;
|
||||||
@ -7227,20 +7263,26 @@ static int _process_switches(int *argcp, char ***argvp, const char *dev_dir)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
dm_set_name_mangling_mode((dm_string_mangling_t) _int_args[MANGLENAME_ARG]);
|
dm_set_name_mangling_mode((dm_string_mangling_t) _int_args[MANGLENAME_ARG]);
|
||||||
}
|
break;
|
||||||
if (ind == NAMEPREFIXES_ARG)
|
case NAMEPREFIXES_ARG:
|
||||||
_switches[NAMEPREFIXES_ARG]++;
|
_switches[NAMEPREFIXES_ARG]++;
|
||||||
if (ind == NOFLUSH_ARG)
|
break;
|
||||||
|
case NOFLUSH_ARG:
|
||||||
_switches[NOFLUSH_ARG]++;
|
_switches[NOFLUSH_ARG]++;
|
||||||
if (ind == NOGROUP_ARG)
|
break;
|
||||||
|
case NOGROUP_ARG:
|
||||||
_switches[NOGROUP_ARG]++;
|
_switches[NOGROUP_ARG]++;
|
||||||
if (ind == NOHEADINGS_ARG)
|
break;
|
||||||
|
case NOHEADINGS_ARG:
|
||||||
_switches[NOHEADINGS_ARG]++;
|
_switches[NOHEADINGS_ARG]++;
|
||||||
if (ind == NOLOCKFS_ARG)
|
break;
|
||||||
|
case NOLOCKFS_ARG:
|
||||||
_switches[NOLOCKFS_ARG]++;
|
_switches[NOLOCKFS_ARG]++;
|
||||||
if (ind == NOOPENCOUNT_ARG)
|
break;
|
||||||
|
case NOOPENCOUNT_ARG:
|
||||||
_switches[NOOPENCOUNT_ARG]++;
|
_switches[NOOPENCOUNT_ARG]++;
|
||||||
if (ind == READAHEAD_ARG) {
|
break;
|
||||||
|
case READAHEAD_ARG:
|
||||||
_switches[READAHEAD_ARG]++;
|
_switches[READAHEAD_ARG]++;
|
||||||
if (!strcasecmp(optarg, "auto"))
|
if (!strcasecmp(optarg, "auto"))
|
||||||
_int_args[READAHEAD_ARG] = DM_READ_AHEAD_AUTO;
|
_int_args[READAHEAD_ARG] = DM_READ_AHEAD_AUTO;
|
||||||
@ -7259,28 +7301,36 @@ static int _process_switches(int *argcp, char ***argvp, const char *dev_dir)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
break;
|
||||||
if (ind == RETRY_ARG)
|
case RETRY_ARG:
|
||||||
_switches[RETRY_ARG]++;
|
_switches[RETRY_ARG]++;
|
||||||
if (ind == ROWS_ARG)
|
break;
|
||||||
|
case ROWS_ARG:
|
||||||
_switches[ROWS_ARG]++;
|
_switches[ROWS_ARG]++;
|
||||||
if (ind == SETUUID_ARG)
|
break;
|
||||||
|
case SETUUID_ARG:
|
||||||
_switches[SETUUID_ARG]++;
|
_switches[SETUUID_ARG]++;
|
||||||
if (ind == SHOWKEYS_ARG)
|
break;
|
||||||
|
case SHOWKEYS_ARG:
|
||||||
_switches[SHOWKEYS_ARG]++;
|
_switches[SHOWKEYS_ARG]++;
|
||||||
if (ind == TABLE_ARG) {
|
break;
|
||||||
|
case TABLE_ARG:
|
||||||
_switches[TABLE_ARG]++;
|
_switches[TABLE_ARG]++;
|
||||||
if (!(_table = strdup(optarg))) {
|
if (!(_table = strdup(optarg))) {
|
||||||
log_error("Could not allocate memory for table string.");
|
log_error("Could not allocate memory for table string.");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
break;
|
||||||
if (ind == TREE_ARG)
|
case TREE_ARG:
|
||||||
_switches[TREE_ARG]++;
|
_switches[TREE_ARG]++;
|
||||||
if (ind == UNQUOTED_ARG)
|
break;
|
||||||
|
case UNQUOTED_ARG:
|
||||||
_switches[UNQUOTED_ARG]++;
|
_switches[UNQUOTED_ARG]++;
|
||||||
if (ind == VERSION_ARG)
|
break;
|
||||||
|
case VERSION_ARG:
|
||||||
_switches[VERSION_ARG]++;
|
_switches[VERSION_ARG]++;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_switches[VERBOSE_ARG] > 1) {
|
if (_switches[VERBOSE_ARG] > 1) {
|
||||||
|
Loading…
Reference in New Issue
Block a user