]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
wdctl: add --flags-only and optional column DEVICE
authorKarel Zak <kzak@redhat.com>
Fri, 18 May 2012 13:08:31 +0000 (15:08 +0200)
committerKarel Zak <kzak@redhat.com>
Fri, 18 May 2012 13:08:31 +0000 (15:08 +0200)
Signed-off-by: Karel Zak <kzak@redhat.com>
sys-utils/wdctl.8
sys-utils/wdctl.c

index 3abe395dd0b7fd4366960c724b4252791d63e73f..8bb1d5c6c212373685ed4daaaf39a4c83e36d984 100644 (file)
@@ -37,6 +37,8 @@ Use key="value" output format.
 Output version information and exit.
 .IP "\fB\-r, \-\-raw\fP"
 Use the raw output format.
+.IP "\fB\-x, \-\-flags-only\fP"
+Same as \fB\-I \-T\fP.
 .IP "\fB\-h, \-\-help\fP"
 Print a help text and exit.
 
index 510cbeaf1b6689c5f7b8a2e3f2e3074e2f60ade4..093240e79f2747baa3baef0c5780de7a0cb6c779 100644 (file)
@@ -62,14 +62,16 @@ struct colinfo {
        const char *help;
 };
 
-enum { COL_FLAG, COL_DESC, COL_STATUS, COL_BSTATUS };
+enum { COL_FLAG, COL_DESC, COL_STATUS, COL_BSTATUS, COL_DEVICE };
 
 /* columns descriptions */
 static struct colinfo infos[] = {
        [COL_FLAG]    = { "FLAG",        14,  0, N_("flag name") },
        [COL_DESC]    = { "DESCRIPTION", 0.1, TT_FL_TRUNC, N_("flag description") },
        [COL_STATUS]  = { "STATUS",      1,   TT_FL_RIGHT, N_("flag status") },
-       [COL_BSTATUS] = { "BOOT-STATUS", 1,   TT_FL_RIGHT, N_("flag boot status") }
+       [COL_BSTATUS] = { "BOOT-STATUS", 1,   TT_FL_RIGHT, N_("flag boot status") },
+       [COL_DEVICE]  = { "DEVICE",      0.1, 0, N_("watchdog device name") }
+
 };
 
 #define NCOLS ARRAY_SIZE(infos)
@@ -146,6 +148,7 @@ static void usage(FILE *out)
              _(" -d, --device <path>   device to use (default is %s)\n"), _PATH_WATCHDOG_DEV);
 
        fputs(_(" -f, --flags <list>    print selected flags only\n"
+               " -x, --flags-only      print only flags table (same as -I -T)\n"
                " -F, --noflags         don't print information about flags\n"
                " -n, --noheadings      don't print headings\n"
                " -I, --noident         don't print watchdog identity information\n"
@@ -195,6 +198,9 @@ static void add_flag_line(struct tt *tt, struct wdinfo *wd, const struct wdflag
                case COL_BSTATUS:
                        str = wd->bstatus & fl->flag ? "1" : "0";
                        break;
+               case COL_DEVICE:
+                       str = wd->device;
+                       break;
                default:
                        break;
                }
@@ -334,6 +340,7 @@ int main(int argc, char *argv[])
        static const struct option long_opts[] = {
                { "device",     required_argument, NULL, 'd' },
                { "flags",      required_argument, NULL, 'f' },
+               { "flags-only", no_argument,       NULL, 'x' },
                { "help",       no_argument,       NULL, 'h' },
                { "noflags",    no_argument,       NULL, 'F' },
                { "noheadings", no_argument,       NULL, 'n' },
@@ -352,7 +359,7 @@ int main(int argc, char *argv[])
        atexit(close_stdout);
 
        while ((c = getopt_long(argc, argv,
-                               "d:f:hFnITo:PrV", long_opts, NULL)) != -1) {
+                               "d:f:hFnITo:PrVx", long_opts, NULL)) != -1) {
                switch(c) {
                case 'd':
                        wd.device = optarg;
@@ -391,6 +398,10 @@ int main(int argc, char *argv[])
                case 'P':
                        tt_flags |= TT_FL_EXPORT;
                        break;
+               case 'x':
+                       noident = 1;
+                       notimeouts = 1;
+                       break;
 
                case '?':
                default:
@@ -416,11 +427,13 @@ int main(int argc, char *argv[])
        if (rc)
                goto done;
 
-       if (!noident)
+       if (!noident) {
+               printf("%-15s%s\n", _("Device:"), wd.device);
                printf(_("%-15s%s [version %x]\n"),
                                ("Identity:"),
                                wd.ident.identity,
                                wd.ident.firmware_version);
+       }
        if (!notimeouts)
                show_timeouts(&wd);
        if (!noflags && !(noident && notimeouts))