Commit Graph

42 Commits

Author SHA1 Message Date
Patrick Steinhardt cdd2d60e56 wdctl: remove duplicate include of <unistd.h>
The <unistd.h> header is included twice in "wdctl.c". Remove one
of these includes to keep "make checkincludes" happy.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
2019-08-19 15:00:35 +02:00
Karel Zak b3dd29d1b8 wdctl; read from /sys if necessary
The device can be inaccessible for non-root user or busy (already used
by another process). In this case it seems better to read information
from /sys.

Note that /sys does not provide struct watchdog_info.options, so we
cannot print list of supported watchdog features.

Addresses: https://github.com/karelzak/util-linux/issues/804
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-06-17 15:47:39 +02:00
Karel Zak 8c8df42146 wdctl: default to /dev/watchdog0
Let's use miscdev /dev/watchdog as fallback only. We need (if possible)
cdev /dev/watchdog0 as this device has entry in /sys/class/watchdog.

Signed-off-by: Karel Zak <kzak@redhat.com>
2019-06-17 15:47:39 +02:00
Karel Zak 5d628f37b7 wdctl: remove printing from main()
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-06-17 15:47:39 +02:00
Karel Zak a599d1375e wdctl: add control struct
* remove global variables
* keep all together

Signed-off-by: Karel Zak <kzak@redhat.com>
2019-06-17 15:47:39 +02:00
Karel Zak e4d511d40c wdctl: rename watch dog info struct
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-06-17 15:47:39 +02:00
Karel Zak 2c308875a7 misc: consolidate version printing and close_stdout()
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-04-16 15:14:13 +02:00
Sami Kerola 4aaabaa9f4 wdctl: do not call fsync(2) when closing watchdog device
This removes bogus write failed warning.

$ wdctl
wdctl: write failed: Invalid argument
Device:        /dev/watchdog
[...]

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2017-07-31 13:48:04 +02:00
Ruediger Meier f45f3ec34a misc: consolidate macro style USAGE_HELP_OPTIONS
changed in include/c.h and applied via sed:

  sed -i 's/fprintf.*\(USAGE_MAN_TAIL.*\)/printf(\1/' $(git ls-files -- "*.c")
  sed -i 's/print_usage_help_options\(.*\);/printf(USAGE_HELP_OPTIONS\1);/' $(git ls-files -- "*.c")

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2017-06-29 16:54:33 +02:00
Ruediger Meier b1a294c448 misc: introduce print_usage_help_options()
Consolidate --help and --version descriptions. We are
now able to align them to the other options.

We changed include/c.h. The rest of this patch was
generated by sed, plus manually setting the right
alignment numbers. We do not change anything but
white spaces in the --help output.

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2017-06-27 12:26:19 +02:00
Ruediger Meier 86be6a32d3 misc: cosmetics, remove argument from usage(FILE*)
This patch is trivial and changes nothing, because
we were always using usage(stdout)

Now all our usage() functions look very similar. If wanted we
could auto-generate another big cosmetical patch to remove all
the useless "FILE *out" constants and use printf and puts
rather than their f* friends. Such patch could be automatically
synchronized with the translation project (newlines!) to not
make the translators sick.

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2017-06-26 14:38:24 +02:00
J William Piggott 6e2d5a4460 include/c.h: add USAGE_COMMANDS and USAGE_COLUMNS
* login-utils/lslogins.c: all uses changed
* misc-utils/findmnt.c: likewise
* sys-utils/blkzone.c: likewise
* disk-utils/sfdisk.c: likewise
* sys-utils/lscpu.c: likewise
* sys-utils/lsmem.c: likewise
* sys-utils/wdctl.c: likewise

Signed-off-by: J William Piggott <elseifthen@gmx.com>
2017-06-24 13:57:12 -04:00
Karel Zak 780ce22cda misc: consolidate smartcols error messages
... just to keep translators happy

Signed-off-by: Karel Zak <kzak@redhat.com>
2017-05-18 11:39:34 +02:00
Yuri Chornoivan a7349ee315 docs: Fix word repetitions 2017-02-13 14:10:12 +01:00
Karel Zak 677ec86cef Use --help suggestion on invalid option
The current default is to print all usage() output. This is overkill
in many case.

Addresses: https://github.com/karelzak/util-linux/issues/338
Signed-off-by: Karel Zak <kzak@redhat.com>
2016-12-19 13:13:34 +01:00
Karel Zak 2df4efb934 wdct: mark usage() as noreturn [coverity scan] 2016-10-05 11:25:17 +02:00
Benno Schulenberg 451dbcfae1 textual: add a docstring to most of the utilities
This adds a concise description of a tool to its usage text.

A first form of this patch was proposed by Steven Honeyman
(see http://www.spinics.net/lists/util-linux-ng/msg09994.html).

Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
2015-01-06 11:27:38 +01:00
Karel Zak 059a91f8d0 wdctl: clean up columns[] usage
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-07-18 13:50:33 +02:00
Karel Zak 710ed55dcd libsmartcols: add debug messages
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-06-06 13:47:06 +02:00
Karel Zak 0925a9dd6c libsmartcols: clean up flags usage
* rename flags functions to scols_table_enable_*
 * rename *_no_foo() functions to _nofoo()
 * output formats are mutually exclusive, so don't use flags there
 * don't assume symbols in scols_new_table(), use scols_table_set_symbols()

Signed-off-by: Karel Zak <kzak@redhat.com>
2014-04-03 16:09:57 +02:00
Karel Zak 98f87c507d wdctl: clean up scols usage
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-04-03 12:29:21 +02:00
Ondrej Oprala fe7af530a9 wdctl: use libsmartcols
Signed-off-by: Ondrej Oprala <ooprala@redhat.com>
2014-04-03 12:29:19 +02:00
Benno Schulenberg ce0e6110b6 wdctl: pluralize one thrice-repeated message
Also put in one hard space, to keep text and number separated when
the translated string should be too long.

Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
2013-10-08 15:27:36 +02:00
Benno Schulenberg 5b831eb199 wdctl: gettextize and pluralize one forgotten message
Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
2013-10-08 15:27:36 +02:00
Karel Zak 2ffddb6a0b wdctl: use TT_FL_FREEDATA for tt table
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-09-16 16:46:59 +02:00
Sami Kerola 3757e57f7b wdctl: check writing to a file descriptor was successful
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2013-04-26 13:26:06 +02:00
Karel Zak 2eb5ba0bd4 wdctl: add fallbacks for old kernel headers
Reported-by: Moritz Barsnick <barsnick@gmx.net>
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-09-07 18:08:55 +02:00
Benno Schulenberg b8ccc27c1b wdctl: treat aligned translatable strings in a uniform manner
Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
2012-09-04 17:28:19 +02:00
Benno Schulenberg 19c19b637d wdctl: gettextize one forgotten word
Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
2012-09-04 17:28:16 +02:00
Harald Hoyer fb8b62df37 wdctl: add "--settimeout" to set the timeout
[kzak@redhat.com: - fix usage() and man page]

Signed-off-by: Karel Zak <kzak@redhat.com>
Signed-off-by: Harald Hoyer <harald@redhat.com>
2012-08-02 19:23:15 +02:00
Sami Kerola 7560aebe7e wdctl: fix conflicting types on old systems
The program wants the userland version of declaration(s), not the
kernel one.  Problem occured with glibc-devel-2.5-34.

/usr/include/stdint.h:41: error: conflicting types for 'int64_t'
/usr/include/linux/types.h:98: error: previous declaration of 'int64_t' was here
/usr/include/stdint.h:56: error: conflicting types for 'uint64_t'
/usr/include/linux/types.h:96: error: previous declaration of 'uint64_t' was here
In file included from /usr/include/stdlib.h:438,
                 from ./include/c.h:13,
                 from sys-utils/wdctl.c:30:

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-07-26 13:51:42 +02:00
Karel Zak 1c608be18c wdctl: use err_exclusive_options()
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-07-26 09:26:51 +02:00
Sami Kerola 289dcc9023 translation: unify file open error messages
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-07-16 18:18:22 +02:00
Sami Kerola 62b4528a8b wdctl: correct manual section reference
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-06-17 17:59:59 +02:00
Sami Kerola e6dbcc4a20 wdctl: use exclusive_option()
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-06-17 17:59:59 +02:00
Karel Zak 9561d1afea wdctl: add --oneline
* remove --pairs, it was usable for flags table only

 * one line for each watchdog device

For example:

 # wdctl --noident --noflags --oneline
 /dev/watchdog: TIMEOUT="30" TIMELEFT="2"

Signed-off-by: Karel Zak <kzak@redhat.com>
2012-05-22 13:31:46 +02:00
Karel Zak f56338b439 wdctl: allow to specify more than one device
* remove -d <device> option

 * support wdctl [options] [<device> ...] usage

Signed-off-by: Karel Zak <kzak@redhat.com>
2012-05-22 11:48:36 +02:00
Karel Zak 96747e7594 wdctl: add --flags-only and optional column DEVICE
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-05-18 15:08:31 +02:00
Karel Zak 3dd00e0773 wdctl: make timeouts output more parsable
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-05-04 11:02:47 +02:00
Karel Zak 09f9a393a4 wdctl: rewrite to use lib/tt
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-05-03 17:29:31 +02:00
Sami Kerola 33a0de92e9 wdctl: align with other util-linux commands
* Add watchdog device path to pathnames.h
* Check output stream status at exit.
* Adjust usage() notation to follow howto file.
* Retire numeric return value.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-05-03 15:00:07 +02:00
Lennart Poettering 8fb6a2de79 wdctl: add watchdog status tool
For: util-linux

This patch adds a tiny tool "wdctl" which may be used to query the
status of Linux watchdog devices (/dev/watchdog).

This will simply query all fields that may be queried from the
device and print them nicely formatted.

Signed-off-by: Lennart Poettering <lennart@poettering.net>
2012-04-16 14:24:49 +02:00