mirror of
git://sourceware.org/git/lvm2.git
synced 2025-10-03 01:44:19 +03:00
Compare commits
1 Commits
dev-dct-cm
...
dev-dct-cm
Author | SHA1 | Date | |
---|---|---|---|
|
8e85c41dc7 |
@@ -280,7 +280,7 @@ OO_LVCONVERT: --alloc Alloc, --background, --force, --noudevsync,
|
||||
# current LV type.
|
||||
|
||||
lvconvert --merge LV_linear_striped_raid_thin_snapshot|VG|Tag ...
|
||||
OO: --background, --interval Number
|
||||
OO: --background, --interval Number, OO_LVCONVERT
|
||||
ID: lvconvert_merge
|
||||
DESC: Merge LV that was previously split from a mirror.
|
||||
DESC: Merge thin LV into its origin LV.
|
||||
@@ -563,6 +563,7 @@ DESC: Separate a COW snapshot from its origin LV.
|
||||
# The purpose of this command is not entirely clear.
|
||||
|
||||
lvconvert LV_mirror
|
||||
OO: OO_LVCONVERT
|
||||
ID: lvconvert_poll_mirror
|
||||
DESC: Poll mirror LV to collapse resync layers.
|
||||
|
||||
@@ -571,6 +572,7 @@ DESC: Poll mirror LV to collapse resync layers.
|
||||
# FIXME: add a new option defining this operation, e.g. --swapmetadata
|
||||
|
||||
lvconvert --poolmetadata LV LV_thinpool_cachepool
|
||||
OO: OO_LVCONVERT
|
||||
ID: lvconvert_swap_pool_metadata
|
||||
DESC: Swap metadata LV in a thin pool or cache pool (temporary command).
|
||||
|
||||
@@ -896,7 +898,7 @@ DESC: (infers --type thin).
|
||||
DESC: Create a sparse snapshot of a virtual origin LV
|
||||
DESC: (infers --type snapshot).
|
||||
DESC: Chooses --type thin or --type snapshot according to
|
||||
DESC: confing setting sparse_segtype_default.
|
||||
DESC: config setting sparse_segtype_default.
|
||||
|
||||
---
|
||||
|
||||
|
@@ -108,6 +108,8 @@ static struct opt_name opt_names[ARG_COUNT + 1] = {
|
||||
struct cmd_name {
|
||||
const char *name;
|
||||
const char *desc;
|
||||
int variants;
|
||||
int common_options[ARG_COUNT + 1];
|
||||
};
|
||||
|
||||
/* create table of command names, e.g. vgcreate */
|
||||
@@ -133,7 +135,7 @@ struct oo_line {
|
||||
int cmd_count;
|
||||
struct command cmd_array[MAX_CMDS];
|
||||
|
||||
struct command common_options; /* for printing common usage */
|
||||
struct command lvm_all; /* for printing common options for all lvm commands */
|
||||
|
||||
#define MAX_OO_LINES 256
|
||||
int oo_line_count;
|
||||
@@ -499,6 +501,19 @@ static const char *cmd_name_desc(const char *name)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static struct cmd_name *find_command_name(const char *str)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < MAX_CMD_NAMES; i++) {
|
||||
if (!cmd_names[i].name)
|
||||
break;
|
||||
if (!strcmp(cmd_names[i].name, str))
|
||||
return &cmd_names[i];
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static int is_opt_name(char *str)
|
||||
{
|
||||
if (!strncmp(str, "--", 2))
|
||||
@@ -1173,35 +1188,156 @@ void print_command_count(void)
|
||||
printf("};\n");
|
||||
}
|
||||
|
||||
static int is_common_opt(int opt)
|
||||
static int is_lvm_all_opt(int opt)
|
||||
{
|
||||
int oo;
|
||||
|
||||
for (oo = 0; oo < common_options.oo_count; oo++) {
|
||||
if (common_options.optional_opt_args[oo].opt == opt)
|
||||
for (oo = 0; oo < lvm_all.oo_count; oo++) {
|
||||
if (lvm_all.optional_opt_args[oo].opt == opt)
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* For certain commands (esp commands like lvcreate with many variants), common
|
||||
* options should not be printed for every variation, but once for all. The
|
||||
* list of commands this applies to is fixed for now but could be encoded in
|
||||
* command-lines.in.
|
||||
*
|
||||
* The common options are defined in OO_USAGE_COMMON. Those options
|
||||
* are skipped when creating the usage strings for each variation of
|
||||
* these commands. Instead they are set in the usage_common string.
|
||||
*/
|
||||
|
||||
void print_usage(struct command *cmd, int skip_required)
|
||||
static void factor_common_options(void)
|
||||
{
|
||||
int onereq = (cmd->cmd_flags & CMD_FLAG_ONE_REQUIRED_OPT) ? 1 : 0;
|
||||
int i, sep, ro, rp, oo, op;
|
||||
int cn, opt_enum, ci, oo, found;
|
||||
struct command *cmd;
|
||||
|
||||
if (skip_required)
|
||||
goto oo_count;
|
||||
for (cn = 0; cn < MAX_CMD_NAMES; cn++) {
|
||||
if (!cmd_names[cn].name)
|
||||
break;
|
||||
|
||||
for (ci = 0; ci < cmd_count; ci++) {
|
||||
cmd = &cmd_array[ci];
|
||||
|
||||
if (strcmp(cmd->name, cmd_names[cn].name))
|
||||
continue;
|
||||
|
||||
cmd_names[cn].variants++;
|
||||
}
|
||||
|
||||
for (opt_enum = 0; opt_enum < ARG_COUNT; opt_enum++) {
|
||||
|
||||
for (ci = 0; ci < cmd_count; ci++) {
|
||||
cmd = &cmd_array[ci];
|
||||
|
||||
if (strcmp(cmd->name, cmd_names[cn].name))
|
||||
continue;
|
||||
|
||||
found = 0;
|
||||
|
||||
for (oo = 0; oo < cmd->oo_count; oo++) {
|
||||
if (cmd->optional_opt_args[oo].opt == opt_enum) {
|
||||
found = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!found)
|
||||
goto next_opt;
|
||||
}
|
||||
|
||||
/* all commands starting with this name use this option */
|
||||
cmd_names[cn].common_options[opt_enum] = 1;
|
||||
next_opt:
|
||||
;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
for (cn = 0; cn < MAX_CMD_NAMES; cn++) {
|
||||
if (!cmd_names[cn].name)
|
||||
break;
|
||||
|
||||
printf("%s (%d)\n", cmd_names[cn].name, cmd_names[cn].variants);
|
||||
for (opt_enum = 0; opt_enum < ARG_COUNT; opt_enum++) {
|
||||
if (cmd_names[cn].common_options[opt_enum])
|
||||
printf(" %s\n", opt_names[opt_enum].long_opt);
|
||||
}
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
void print_usage_common(struct command *cmd)
|
||||
{
|
||||
struct cmd_name *cname;
|
||||
int i, sep, ro, rp, oo, op, opt_enum;
|
||||
|
||||
if (!(cname = find_command_name(cmd->name)))
|
||||
return;
|
||||
|
||||
sep = 0;
|
||||
|
||||
/*
|
||||
* when there's more than one variant, options that
|
||||
* are common to all commands with a common name.
|
||||
*/
|
||||
|
||||
if (cname->variants < 2)
|
||||
goto all;
|
||||
|
||||
for (opt_enum = 0; opt_enum < ARG_COUNT; opt_enum++) {
|
||||
if (!cname->common_options[opt_enum])
|
||||
continue;
|
||||
|
||||
if (is_lvm_all_opt(opt_enum))
|
||||
continue;
|
||||
|
||||
if (!sep) {
|
||||
printf("\n");
|
||||
printf("\" [");
|
||||
} else {
|
||||
printf(",");
|
||||
}
|
||||
|
||||
for (oo = 0; oo < cmd->oo_count; oo++) {
|
||||
if (cmd->optional_opt_args[oo].opt != opt_enum)
|
||||
continue;
|
||||
|
||||
printf(" %s", opt_names[opt_enum].long_opt);
|
||||
if (cmd->optional_opt_args[oo].def.val_bits) {
|
||||
printf(" ");
|
||||
print_def(&cmd->optional_opt_args[oo].def, 1);
|
||||
}
|
||||
sep = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
all:
|
||||
/* options that are common to all lvm commands */
|
||||
|
||||
for (oo = 0; oo < lvm_all.oo_count; oo++) {
|
||||
opt_enum = lvm_all.optional_opt_args[oo].opt;
|
||||
|
||||
if (!sep) {
|
||||
printf("\n");
|
||||
printf("\" [");
|
||||
} else {
|
||||
printf(",");
|
||||
}
|
||||
|
||||
printf(" %s", opt_names[opt_enum].long_opt);
|
||||
if (lvm_all.optional_opt_args[oo].def.val_bits) {
|
||||
printf(" ");
|
||||
print_def(&lvm_all.optional_opt_args[oo].def, 1);
|
||||
}
|
||||
sep = 1;
|
||||
}
|
||||
|
||||
printf(" ]\"");
|
||||
printf(";\n");
|
||||
}
|
||||
|
||||
void print_usage(struct command *cmd)
|
||||
{
|
||||
struct cmd_name *cname;
|
||||
int onereq = (cmd->cmd_flags & CMD_FLAG_ONE_REQUIRED_OPT) ? 1 : 0;
|
||||
int i, sep, ro, rp, oo, op, opt_enum;
|
||||
|
||||
if (!(cname = find_command_name(cmd->name)))
|
||||
return;
|
||||
|
||||
printf("\"%s", cmd->name);
|
||||
|
||||
@@ -1240,30 +1376,40 @@ void print_usage(struct command *cmd, int skip_required)
|
||||
sep = 0;
|
||||
|
||||
if (cmd->oo_count) {
|
||||
printf("\n");
|
||||
printf("\" [");
|
||||
|
||||
for (oo = 0; oo < cmd->oo_count; oo++) {
|
||||
/* skip common opts which are in the usage_common string */
|
||||
if ((cmd != &common_options) && is_common_opt(cmd->optional_opt_args[oo].opt))
|
||||
opt_enum = cmd->optional_opt_args[oo].opt;
|
||||
|
||||
/*
|
||||
* Skip common opts which are in the usage_common string.
|
||||
* The common opts are those in lvm_all and in
|
||||
* cname->common_options.
|
||||
*/
|
||||
|
||||
if (is_lvm_all_opt(opt_enum))
|
||||
continue;
|
||||
|
||||
if (!sep) {
|
||||
printf("\n");
|
||||
printf("\" [");
|
||||
}
|
||||
if ((cname->variants > 1) && cname->common_options[opt_enum])
|
||||
continue;
|
||||
|
||||
if (sep)
|
||||
printf(",");
|
||||
|
||||
printf(" %s", opt_names[cmd->optional_opt_args[oo].opt].long_opt);
|
||||
printf(" %s", opt_names[opt_enum].long_opt);
|
||||
if (cmd->optional_opt_args[oo].def.val_bits) {
|
||||
printf(" ");
|
||||
print_def(&cmd->optional_opt_args[oo].def, 1);
|
||||
}
|
||||
sep = 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (sep)
|
||||
if (sep)
|
||||
printf(",");
|
||||
printf(" COMMON_OPTIONS");
|
||||
printf(" ]\"");
|
||||
}
|
||||
|
||||
op_count:
|
||||
if (!cmd->op_count)
|
||||
@@ -1352,7 +1498,7 @@ static void print_def_man(struct arg_def *def, int usage)
|
||||
|
||||
else if (val_enum == constnum_VAL) {
|
||||
printf("\\fB");
|
||||
printf("ll%u", (unsigned long long)def->num);
|
||||
printf("%llu", (unsigned long long)def->num);
|
||||
printf("\\fP");
|
||||
}
|
||||
|
||||
@@ -1393,13 +1539,14 @@ static void print_def_man(struct arg_def *def, int usage)
|
||||
printf(" ...");
|
||||
}
|
||||
|
||||
void print_cmd_man(struct command *cmd, int skip_required)
|
||||
void print_man_usage(struct command *cmd)
|
||||
{
|
||||
struct cmd_name *cname;
|
||||
int onereq = (cmd->cmd_flags & CMD_FLAG_ONE_REQUIRED_OPT) ? 1 : 0;
|
||||
int i, sep, ro, rp, oo, op;
|
||||
int i, sep, ro, rp, oo, op, opt_enum;
|
||||
|
||||
if (skip_required)
|
||||
goto oo_count;
|
||||
if (!(cname = find_command_name(cmd->name)))
|
||||
return;
|
||||
|
||||
printf("\\fB%s\\fP", cmd->name);
|
||||
|
||||
@@ -1424,6 +1571,7 @@ void print_cmd_man(struct command *cmd, int skip_required)
|
||||
|
||||
sep = 0;
|
||||
|
||||
/* print required options with a short opt */
|
||||
for (ro = 0; ro < cmd->ro_count; ro++) {
|
||||
if (!opt_names[cmd->required_opt_args[ro].opt].short_opt)
|
||||
continue;
|
||||
@@ -1451,6 +1599,7 @@ void print_cmd_man(struct command *cmd, int skip_required)
|
||||
sep = 1;
|
||||
}
|
||||
|
||||
/* print required options without a short opt */
|
||||
for (ro = 0; ro < cmd->ro_count; ro++) {
|
||||
if (opt_names[cmd->required_opt_args[ro].opt].short_opt)
|
||||
continue;
|
||||
@@ -1476,6 +1625,7 @@ void print_cmd_man(struct command *cmd, int skip_required)
|
||||
printf(".RE\n");
|
||||
}
|
||||
|
||||
/* print required positional args on a new line after the onereq set */
|
||||
if (cmd->rp_count) {
|
||||
printf(".RS 4\n");
|
||||
for (rp = 0; rp < cmd->rp_count; rp++) {
|
||||
@@ -1498,7 +1648,7 @@ void print_cmd_man(struct command *cmd, int skip_required)
|
||||
|
||||
/*
|
||||
* all are required options, print as:
|
||||
* -a|--a, -b|--b
|
||||
* -a|--aaa <val> -b|--bbb <val>
|
||||
*/
|
||||
|
||||
if (cmd->ro_count) {
|
||||
@@ -1518,6 +1668,7 @@ void print_cmd_man(struct command *cmd, int skip_required)
|
||||
}
|
||||
}
|
||||
|
||||
/* print required positional args on the same line as the required options */
|
||||
if (cmd->rp_count) {
|
||||
for (rp = 0; rp < cmd->rp_count; rp++) {
|
||||
if (cmd->required_pos_args[rp].def.val_bits) {
|
||||
@@ -1539,22 +1690,29 @@ void print_cmd_man(struct command *cmd, int skip_required)
|
||||
|
||||
sep = 0;
|
||||
|
||||
printf(".br\n");
|
||||
|
||||
if (cmd->oo_count) {
|
||||
printf(".RS 4\n");
|
||||
printf("[");
|
||||
|
||||
/* print optional options with short opts */
|
||||
|
||||
for (oo = 0; oo < cmd->oo_count; oo++) {
|
||||
/* skip common opts which are in the usage_common string */
|
||||
if ((cmd != &common_options) && is_common_opt(cmd->optional_opt_args[oo].opt))
|
||||
opt_enum = cmd->optional_opt_args[oo].opt;
|
||||
|
||||
if (!opt_names[opt_enum].short_opt)
|
||||
continue;
|
||||
|
||||
if (!opt_names[cmd->optional_opt_args[oo].opt].short_opt)
|
||||
/*
|
||||
* Skip common opts which are in the usage_common string.
|
||||
* The common opts are those in lvm_all and in
|
||||
* cname->common_options.
|
||||
*/
|
||||
|
||||
if (is_lvm_all_opt(opt_enum))
|
||||
continue;
|
||||
|
||||
if (!sep) {
|
||||
printf(".RS 4\n");
|
||||
printf("[");
|
||||
}
|
||||
if ((cname->variants > 1) && cname->common_options[opt_enum])
|
||||
continue;
|
||||
|
||||
if (sep) {
|
||||
printf(",");
|
||||
@@ -1563,8 +1721,8 @@ void print_cmd_man(struct command *cmd, int skip_required)
|
||||
}
|
||||
|
||||
printf(" \\fB-%c\\fP|\\fB%s\\fP",
|
||||
opt_names[cmd->optional_opt_args[oo].opt].short_opt,
|
||||
opt_names[cmd->optional_opt_args[oo].opt].long_opt);
|
||||
opt_names[opt_enum].short_opt,
|
||||
opt_names[opt_enum].long_opt);
|
||||
|
||||
if (cmd->optional_opt_args[oo].def.val_bits) {
|
||||
printf(" ");
|
||||
@@ -1573,18 +1731,25 @@ void print_cmd_man(struct command *cmd, int skip_required)
|
||||
sep = 1;
|
||||
}
|
||||
|
||||
/* print optional options without short opts */
|
||||
|
||||
for (oo = 0; oo < cmd->oo_count; oo++) {
|
||||
/* skip common opts which are in the usage_common string */
|
||||
if ((cmd != &common_options) && is_common_opt(cmd->optional_opt_args[oo].opt))
|
||||
opt_enum = cmd->optional_opt_args[oo].opt;
|
||||
|
||||
if (opt_names[opt_enum].short_opt)
|
||||
continue;
|
||||
|
||||
if (opt_names[cmd->optional_opt_args[oo].opt].short_opt)
|
||||
/*
|
||||
* Skip common opts which are in the usage_common string.
|
||||
* The common opts are those in lvm_all and in
|
||||
* cname->common_options.
|
||||
*/
|
||||
|
||||
if (is_lvm_all_opt(opt_enum))
|
||||
continue;
|
||||
|
||||
if (!sep) {
|
||||
printf(".RS 4\n");
|
||||
printf("[");
|
||||
}
|
||||
if ((cname->variants > 1) && cname->common_options[opt_enum])
|
||||
continue;
|
||||
|
||||
if (sep) {
|
||||
printf(",");
|
||||
@@ -1595,7 +1760,7 @@ void print_cmd_man(struct command *cmd, int skip_required)
|
||||
/* space alignment without short opt */
|
||||
printf(" ");
|
||||
|
||||
printf(" \\fB%s\\fP", opt_names[cmd->optional_opt_args[oo].opt].long_opt);
|
||||
printf(" \\fB%s\\fP", opt_names[opt_enum].long_opt);
|
||||
|
||||
if (cmd->optional_opt_args[oo].def.val_bits) {
|
||||
printf(" ");
|
||||
@@ -1603,9 +1768,15 @@ void print_cmd_man(struct command *cmd, int skip_required)
|
||||
}
|
||||
sep = 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (sep) {
|
||||
if (sep) {
|
||||
printf(",");
|
||||
printf("\n.br\n");
|
||||
printf(" ");
|
||||
/* space alignment without short opt */
|
||||
printf(" ");
|
||||
}
|
||||
printf(" COMMON_OPTIONS");
|
||||
printf(" ]\n");
|
||||
printf(".RE\n");
|
||||
printf(".br\n");
|
||||
@@ -1634,6 +1805,151 @@ void print_cmd_man(struct command *cmd, int skip_required)
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
void print_man_usage_common(struct command *cmd)
|
||||
{
|
||||
struct cmd_name *cname;
|
||||
int i, sep, ro, rp, oo, op, opt_enum;
|
||||
|
||||
if (!(cname = find_command_name(cmd->name)))
|
||||
return;
|
||||
|
||||
sep = 0;
|
||||
|
||||
printf(".RS 4\n");
|
||||
printf("[");
|
||||
|
||||
/*
|
||||
* when there's more than one variant, options that
|
||||
* are common to all commands with a common name.
|
||||
*/
|
||||
|
||||
if (cname->variants < 2)
|
||||
goto all;
|
||||
|
||||
/* print those with short opts */
|
||||
for (opt_enum = 0; opt_enum < ARG_COUNT; opt_enum++) {
|
||||
if (!cname->common_options[opt_enum])
|
||||
continue;
|
||||
|
||||
if (!opt_names[opt_enum].short_opt)
|
||||
continue;
|
||||
|
||||
if (is_lvm_all_opt(opt_enum))
|
||||
continue;
|
||||
|
||||
if (sep) {
|
||||
printf(",");
|
||||
printf("\n.br\n");
|
||||
printf(" ");
|
||||
}
|
||||
|
||||
for (oo = 0; oo < cmd->oo_count; oo++) {
|
||||
if (cmd->optional_opt_args[oo].opt != opt_enum)
|
||||
continue;
|
||||
|
||||
printf(" \\fB-%c\\fP|\\fB%s\\fP",
|
||||
opt_names[opt_enum].short_opt,
|
||||
opt_names[opt_enum].long_opt);
|
||||
|
||||
if (cmd->optional_opt_args[oo].def.val_bits) {
|
||||
printf(" ");
|
||||
print_def_man(&cmd->optional_opt_args[oo].def, 1);
|
||||
}
|
||||
sep = 1;
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/* print those without short opts */
|
||||
for (opt_enum = 0; opt_enum < ARG_COUNT; opt_enum++) {
|
||||
if (!cname->common_options[opt_enum])
|
||||
continue;
|
||||
|
||||
if (opt_names[opt_enum].short_opt)
|
||||
continue;
|
||||
|
||||
if (is_lvm_all_opt(opt_enum))
|
||||
continue;
|
||||
|
||||
if (sep) {
|
||||
printf(",");
|
||||
printf("\n.br\n");
|
||||
printf(" ");
|
||||
}
|
||||
|
||||
for (oo = 0; oo < cmd->oo_count; oo++) {
|
||||
if (cmd->optional_opt_args[oo].opt != opt_enum)
|
||||
continue;
|
||||
|
||||
/* space alignment without short opt */
|
||||
printf(" ");
|
||||
|
||||
printf(" \\fB%s\\fP", opt_names[opt_enum].long_opt);
|
||||
|
||||
if (cmd->optional_opt_args[oo].def.val_bits) {
|
||||
printf(" ");
|
||||
print_def_man(&cmd->optional_opt_args[oo].def, 1);
|
||||
}
|
||||
sep = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
all:
|
||||
/* options that are common to all lvm commands */
|
||||
|
||||
/* those with short opts */
|
||||
for (oo = 0; oo < lvm_all.oo_count; oo++) {
|
||||
opt_enum = lvm_all.optional_opt_args[oo].opt;
|
||||
|
||||
if (!opt_names[opt_enum].short_opt)
|
||||
continue;
|
||||
|
||||
if (sep) {
|
||||
printf(",");
|
||||
printf("\n.br\n");
|
||||
printf(" ");
|
||||
}
|
||||
|
||||
printf(" \\fB-%c\\fP|\\fB%s\\fP",
|
||||
opt_names[opt_enum].short_opt,
|
||||
opt_names[opt_enum].long_opt);
|
||||
|
||||
if (lvm_all.optional_opt_args[oo].def.val_bits) {
|
||||
printf(" ");
|
||||
print_def(&lvm_all.optional_opt_args[oo].def, 1);
|
||||
}
|
||||
sep = 1;
|
||||
}
|
||||
|
||||
/* those without short opts */
|
||||
for (oo = 0; oo < lvm_all.oo_count; oo++) {
|
||||
opt_enum = lvm_all.optional_opt_args[oo].opt;
|
||||
|
||||
if (opt_names[opt_enum].short_opt)
|
||||
continue;
|
||||
|
||||
if (sep) {
|
||||
printf(",");
|
||||
printf("\n.br\n");
|
||||
printf(" ");
|
||||
}
|
||||
|
||||
/* space alignment without short opt */
|
||||
printf(" ");
|
||||
|
||||
printf(" \\fB%s\\fP", opt_names[opt_enum].long_opt);
|
||||
|
||||
if (lvm_all.optional_opt_args[oo].def.val_bits) {
|
||||
printf(" ");
|
||||
print_def(&lvm_all.optional_opt_args[oo].def, 1);
|
||||
}
|
||||
sep = 1;
|
||||
}
|
||||
printf(" ]\"");
|
||||
printf(";\n");
|
||||
}
|
||||
|
||||
#define DESC_LINE 256
|
||||
|
||||
void print_desc_man(const char *desc)
|
||||
@@ -1674,16 +1990,16 @@ void print_desc_man(const char *desc)
|
||||
}
|
||||
}
|
||||
|
||||
void print_command_man(void)
|
||||
void print_man_command(void)
|
||||
{
|
||||
struct command *cmd;
|
||||
const char *last_cmd_name = NULL;
|
||||
const char *desc;
|
||||
int i, j, ro, rp, oo, op;
|
||||
|
||||
include_optional_opt_args(&common_options, "OO_USAGE_COMMON");
|
||||
include_optional_opt_args(&lvm_all, "OO_USAGE_COMMON");
|
||||
|
||||
printf(".TH LVM_ALL 8\n");
|
||||
printf(".TH LVM_COMMANDS 8\n");
|
||||
|
||||
for (i = 0; i < cmd_count; i++) {
|
||||
|
||||
@@ -1711,12 +2027,12 @@ void print_command_man(void)
|
||||
printf(".P\n");
|
||||
}
|
||||
|
||||
print_cmd_man(cmd, 0);
|
||||
print_man_usage(cmd);
|
||||
|
||||
if ((i == (cmd_count - 1)) || strcmp(cmd->name, cmd_array[i+1].name)) {
|
||||
printf("Common options:\n");
|
||||
printf(".\n");
|
||||
print_cmd_man(&common_options, 1);
|
||||
print_man_usage_common(cmd);
|
||||
}
|
||||
|
||||
printf("\n");
|
||||
@@ -1729,7 +2045,7 @@ void print_command_struct(int only_usage)
|
||||
struct command *cmd;
|
||||
int i, j, ro, rp, oo, op;
|
||||
|
||||
include_optional_opt_args(&common_options, "OO_USAGE_COMMON");
|
||||
include_optional_opt_args(&lvm_all, "OO_USAGE_COMMON");
|
||||
|
||||
printf("/* Do not edit. This file is generated by scripts/create-commands */\n");
|
||||
printf("/* using command definitions from scripts/command-lines.in */\n");
|
||||
@@ -1739,8 +2055,8 @@ void print_command_struct(int only_usage)
|
||||
cmd = &cmd_array[i];
|
||||
|
||||
if (only_usage) {
|
||||
print_usage(cmd, 0);
|
||||
print_usage(&common_options, 1);
|
||||
print_usage(cmd);
|
||||
print_usage_common(cmd);
|
||||
printf("\n");
|
||||
continue;
|
||||
}
|
||||
@@ -1759,11 +2075,11 @@ void print_command_struct(int only_usage)
|
||||
|
||||
printf("commands[%d].desc = \"%s\";\n", i, cmd->desc ?: "");
|
||||
printf("commands[%d].usage = ", i);
|
||||
print_usage(cmd, 0);
|
||||
print_usage(cmd);
|
||||
|
||||
if (cmd->oo_count) {
|
||||
printf("commands[%d].usage_common = ", i);
|
||||
print_usage(&common_options, 1);
|
||||
print_usage_common(cmd);
|
||||
} else {
|
||||
printf("commands[%d].usage_common = \"NULL\";\n", i);
|
||||
}
|
||||
@@ -1932,8 +2248,8 @@ static void print_ambiguous(void)
|
||||
}
|
||||
|
||||
printf("Ambiguous commands %d and %d:\n", i, j);
|
||||
print_usage(cmd, 0);
|
||||
print_usage(dup, 0);
|
||||
print_usage(cmd);
|
||||
print_usage(dup);
|
||||
printf("\n");
|
||||
|
||||
dups[found].i = i;
|
||||
@@ -1973,11 +2289,11 @@ static void print_help(int argc, char *argv[])
|
||||
{
|
||||
printf("%s --output struct|count|usage|expanded <filename>\n", argv[0]);
|
||||
printf("\n");
|
||||
printf("struct: print C structures.\n");
|
||||
printf("struct: print C structures for command-lines.h\n");
|
||||
printf("count: print defines and enums for command-lines-count.h\n");
|
||||
printf("ambiguous: print commands differing only by LV types\n");
|
||||
printf("usage: print usage format.\n");
|
||||
printf("expanded: print expanded input format.\n");
|
||||
printf("count: print #define COMMAND_COUNT <Number>\n");
|
||||
printf("ambiguous: print commands differing only by LV types\n");
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
@@ -2143,10 +2459,14 @@ int main(int argc, char *argv[])
|
||||
|
||||
fclose(file);
|
||||
|
||||
factor_common_options();
|
||||
|
||||
if (!outputformat)
|
||||
print_command_struct(1);
|
||||
else if (!strcmp(outputformat, "struct"))
|
||||
else if (!strcmp(outputformat, "struct")) {
|
||||
print_command_struct(0);
|
||||
print_ambiguous();
|
||||
}
|
||||
else if (!strcmp(outputformat, "count"))
|
||||
print_command_count();
|
||||
else if (!strcmp(outputformat, "usage"))
|
||||
@@ -2156,7 +2476,7 @@ int main(int argc, char *argv[])
|
||||
else if (!strcmp(outputformat, "ambiguous"))
|
||||
print_ambiguous();
|
||||
else if (!strcmp(outputformat, "man"))
|
||||
print_command_man();
|
||||
print_man_command();
|
||||
else
|
||||
print_help(argc, argv);
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
@@ -116,8 +116,7 @@ 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")
|
||||
/* FIXME: cling_by_tags is left out of help text because it makes the line wrap */
|
||||
val(alloc_VAL, alloc_arg, "Alloc", "contiguous|cling|normal|anywhere|inherit")
|
||||
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")
|
||||
|
Reference in New Issue
Block a user