]> sourceware.org Git - dm.git/commitdiff
Add --prefixes to dmsetup
authorAlasdair Kergon <agk@redhat.com>
Mon, 21 Apr 2008 11:59:22 +0000 (11:59 +0000)
committerAlasdair Kergon <agk@redhat.com>
Mon, 21 Apr 2008 11:59:22 +0000 (11:59 +0000)
E.g. dmsetup info -c --prefixes

Again, might change the name of this option.

WHATS_NEW
dmsetup/dmsetup.c

index cfc45a29f136108f47f247e9ed02c3046f759e65..2b530b966d43d10512022fea5478e58b37b526e9 100644 (file)
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
 Version 1.02.26 - 
 =================================
+  Add --prefixes to dmsetup.
   Add field name prefix option to reporting functions.
   Calculate string size within dm_pool_grow_object.
 
index d5a3ce9c7ebbfe01610d0593480a4a62cb5fcc3f..f0d7d5a7562b469663d421e851ab4bba34677fb4 100644 (file)
@@ -120,6 +120,7 @@ enum {
        NOOPENCOUNT_ARG,
        NOTABLE_ARG,
        OPTIONS_ARG,
+       PREFIXES_ARG,
        READAHEAD_ARG,
        SEPARATOR_ARG,
        SHOWKEYS_ARG,
@@ -1914,7 +1915,7 @@ static int _report_init(struct command *c)
        char *options = (char *) default_report_options;
        const char *keys = "";
        const char *separator = " ";
-       int aligned = 1, headings = 1, buffered = 1;
+       int aligned = 1, headings = 1, buffered = 1, field_prefixes = 0;
        uint32_t flags = 0;
        size_t len = 0;
        int r = 0;
@@ -1929,6 +1930,11 @@ static int _report_init(struct command *c)
        if (_switches[UNBUFFERED_ARG])
                buffered = 0;
 
+       if (_switches[PREFIXES_ARG]) {
+               aligned = 0;
+               field_prefixes = 1;
+       }
+
        if (_switches[OPTIONS_ARG] && _string_args[OPTIONS_ARG]) {
                if (*_string_args[OPTIONS_ARG] != '+')
                        options = _string_args[OPTIONS_ARG];
@@ -1971,6 +1977,9 @@ static int _report_init(struct command *c)
        if (headings)
                flags |= DM_REPORT_OUTPUT_HEADINGS;
 
+       if (field_prefixes)
+               flags |= DM_REPORT_OUTPUT_FIELD_NAME_PREFIX;
+
        if (!(_report = dm_report_init(&_report_type,
                                       _report_types, _report_fields,
                                       options, separator, flags, keys, NULL)))
@@ -1981,6 +1990,9 @@ static int _report_init(struct command *c)
                goto out;
        }
 
+       if (field_prefixes)
+               dm_report_set_output_field_name_prefix(_report, "dm_");
+
        r = 1;
 
 out:
@@ -2047,7 +2059,7 @@ static void _usage(FILE *out)
                "        [-r|--readonly] [--noopencount] [--nolockfs]\n"
                "        [--readahead [+]<sectors>|auto|none]\n"
                "        [-c|-C|--columns] [-o <fields>] [-O|--sort <sort_fields>]\n"
-               "        [--noheadings] [--separator <separator>]\n\n");
+               "        [--noheadings] [--prefixes] [--separator <separator>]\n\n");
        for (i = 0; _commands[i].name; i++)
                fprintf(out, "\t%s %s\n", _commands[i].name, _commands[i].help);
        fprintf(out, "\n<device> may be device name or -u <uuid> or "
@@ -2409,6 +2421,7 @@ static int _process_switches(int *argc, char ***argv, const char *dev_dir)
                {"noopencount", 0, &ind, NOOPENCOUNT_ARG},
                {"notable", 0, &ind, NOTABLE_ARG},
                {"options", 1, &ind, OPTIONS_ARG},
+               {"prefixes", 0, &ind, PREFIXES_ARG},
                {"readahead", 1, &ind, READAHEAD_ARG},
                {"separator", 1, &ind, SEPARATOR_ARG},
                {"showkeys", 0, &ind, SHOWKEYS_ARG},
@@ -2543,6 +2556,8 @@ static int _process_switches(int *argc, char ***argv, const char *dev_dir)
                        _switches[NOLOCKFS_ARG]++;
                if ((ind == NOOPENCOUNT_ARG))
                        _switches[NOOPENCOUNT_ARG]++;
+               if ((ind == PREFIXES_ARG))
+                       _switches[PREFIXES_ARG]++;
                if ((ind == READAHEAD_ARG)) {
                        _switches[READAHEAD_ARG]++;
                        if (!strcasecmp(optarg, "auto"))
This page took 0.065872 seconds and 5 git commands to generate.