From 68ec42ebaf288911b1cb95882678ca778b795953 Mon Sep 17 00:00:00 2001 From: "Bryn M. Reeves" Date: Sun, 18 Dec 2016 10:53:27 +0000 Subject: [PATCH] dmstats: improve tool help output and option coverage --- tools/dmsetup.c | 104 ++++++++++++++++++++++++++++++++++++------------ 1 file changed, 78 insertions(+), 26 deletions(-) diff --git a/tools/dmsetup.c b/tools/dmsetup.c index f0682931f..1be19d5c9 100644 --- a/tools/dmsetup.c +++ b/tools/dmsetup.c @@ -5608,48 +5608,100 @@ static int _stats_help(CMD_ARGS); * dmsetup stats [options] [device_name] * dmstats [options] [device_name] * - * clear [--regionid id] - * create [--areas nr_areas] [--areasize size] - * [ [--start start] [--length len] | [--segments]] - * [--userdata data] [--programid id] [] - * delete [--regionid] - * delete_all [--programid id] - * group [--alias name] [--alldevices] [--regions ] [] - * list [--programid id] [] - * print [--clear] [--programid id] [--regionid id] [] - * report [--interval seconds] [--count count] [--units units] [--regionid id] - * [--programid id] [] - * ungroup [--alldevices] [--groupid id] [] + * clear [--allregions|--regionid id] [--alldevices|] + * create [--start [--length ] + * [--areas ] [--areasize ] + * [--programid ] [--userdata ] + * [--bounds histogram_boundaries] [--precise] + * [--alldevices|] + * create --filemap [--nogroup] + * [--programid ] [--userdata ] + * [--bounds histogram_boundaries] [--precise] [] + * delete [--allprograms|--programid id] + * [--allregions|--regionid id] + * [--alldevices|] + * group [--alias NAME] --regions + * [--allprograms|--programid id] [--alldevices|] + * list [--allprograms|--programid id] [--allregions|--regionid id] + * print [--clear] [--allprograms|--programid id] + * [--allregions|--regionid id] + * [--alldevices|] + * report [--interval ] [--count ] + * [--units ] [--programid ] [--regionid ] + * [-o ] [-O|--sort ] + * [-S|--select ] [--nameprefixes] + * [--noheadings] [--separator ] + * [--allprograms|--programid id] [] + * ungroup --groupid [--allprograms|--programid id] + * [--alldevices|] */ +#define INDENT "\n\t " +/* groups of commonly used options */ #define AREA_OPTS "[--areas ] [--areasize ] " -#define CREATE_OPTS "[--start [--length ]]\n\t\t" AREA_OPTS +#define REGION_OPTS "[--start [--length ]" INDENT AREA_OPTS #define ID_OPTS "[--programid ] [--userdata ] " #define SELECT_OPTS "[--programid ] [--regionid ] " -#define PRINT_OPTS "[--clear] " SELECT_OPTS -#define REPORT_OPTS "[--interval ] [--count ]\n\t\t[--units ]" SELECT_OPTS -#define GROUP_OPTS "[--alias NAME] --regions " +#define HIST_OPTS "[--bounds histogram_boundaries] " +#define PRECISE_OPTS "[--precise] " +#define SEGMENTS_OPT "[--segments] " +#define EXTRA_OPTS HIST_OPTS PRECISE_OPTS +#define ALL_PROGS_OPT "[--allprograms|--programid id] " +#define ALL_REGIONS_OPT "[--allregions|--regionid id] " +#define ALL_DEVICES_OPT "[--alldevices|] " +#define ALL_PROGS_REGIONS_DEVICES ALL_PROGS_OPT INDENT ALL_REGIONS_OPT INDENT ALL_DEVICES_OPT +#define FIELD_OPTS "[-o ] [-O|--sort ]" +#define DM_REPORT_OPTS FIELD_OPTS INDENT "[-S|--select ] [--nameprefixes]" INDENT \ +"[--noheadings] [--separator ]" + +/* command options */ +#define CREATE_OPTS REGION_OPTS INDENT ID_OPTS INDENT EXTRA_OPTS INDENT SEGMENTS_OPT +#define FILEMAP_OPTS "--filemap [--nogroup]" INDENT ID_OPTS INDENT EXTRA_OPTS +#define PRINT_OPTS "[--clear] " ALL_PROGS_REGIONS_DEVICES +#define REPORT_OPTS "[--interval ] [--count ]" INDENT \ +"[--units ] " SELECT_OPTS INDENT DM_REPORT_OPTS INDENT ALL_PROGS_OPT +#define GROUP_OPTS "[--alias NAME] --regions " INDENT ALL_PROGS_OPT ALL_DEVICES_OPT +#define UNGROUP_OPTS ALL_PROGS_OPT INDENT ALL_DEVICES_OPT +/* + * The 'create' command has two entries in the table, to allow for the + * the fact that 'create' and 'create --filemap' have largely disjoint + * sets of options. + */ static struct command _stats_subcommands[] = { {"help", "", 0, 0, 0, 0, _stats_help}, - {"clear", "--regionid []", 0, -1, 1, 0, _stats_clear}, - {"create", CREATE_OPTS "\n\t\t" ID_OPTS "[]", 0, -1, 1, 0, _stats_create}, - {"delete", "--regionid ", 1, -1, 1, 0, _stats_delete}, + {"clear", ALL_REGIONS_OPT ALL_DEVICES_OPT, 0, -1, 1, 0, _stats_clear}, + {"create", CREATE_OPTS ALL_DEVICES_OPT, 0, -1, 1, 0, _stats_create}, + {"create", FILEMAP_OPTS "[]", 0, -1, 1, 0, _stats_create}, + {"delete", ALL_PROGS_REGIONS_DEVICES, 1, -1, 1, 0, _stats_delete}, {"group", GROUP_OPTS, 1, -1, 1, 0, _stats_group}, - {"list", "[--programid ] []", 0, -1, 1, 0, _stats_report}, - {"print", PRINT_OPTS "[]", 0, -1, 1, 0, _stats_print}, - {"report", REPORT_OPTS "[]", 0, -1, 1, 0, _stats_report}, - {"ungroup", "--groupid [device]", 1, -1, 1, 0, _stats_ungroup}, + {"list", ALL_PROGS_OPT ALL_REGIONS_OPT, 0, -1, 1, 0, _stats_report}, + {"print", PRINT_OPTS, 0, -1, 1, 0, _stats_print}, + {"report", REPORT_OPTS "[]", 0, -1, 1, 0, _stats_report}, + {"ungroup", "--groupid " UNGROUP_OPTS, 1, -1, 1, 0, _stats_ungroup}, {"version", "", 0, -1, 1, 0, _version}, {NULL, NULL, 0, 0, 0, 0, NULL} }; #undef AREA_OPTS -#undef CREATE_OPTS +#undef REGION_OPTS #undef ID_OPTS +#undef SELECT_OPTS +#undef HIST_OPTS +#undef PRECISE_OPTS +#undef EXTRA_OPTS +#undef ALL_PROGS_OPT +#undef ALL_REGIONS_OPT +#undef ALL_DEVICES_OPT +#undef ALL_PROGS_REGIONS_DEVICES +#undef FIELD_OPTS +#undef DM_REPORT_OPTS +#undef CREATE_OPTS +#undef FILEMAP_OPTS #undef PRINT_OPTS #undef REPORT_OPTS -#undef SELECT_OPTS +#undef GROUP_OPTS +#undef UNGROUP_OPTS static int _dmsetup_help(CMD_ARGS); @@ -5723,7 +5775,7 @@ static void _stats_usage(FILE *out) for (i = 0; _stats_subcommands[i].name; i++) fprintf(out, "\t%s %s\n", _stats_subcommands[i].name, _stats_subcommands[i].help); - fprintf(out, " may be device name or -u or " + fprintf(out, "\n may be device name or -u or " "-j -m \n"); fprintf(out, " are comma-separated. Use 'help -c' for list.\n"); fprintf(out, "\n"); -- 2.43.5