Commit Graph

125 Commits

Author SHA1 Message Date
Ruediger Meier c211401801 misc: always cast timeval.tv_usec to long rather than int
Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2016-02-12 14:32:42 +01:00
Karel Zak 3a131296d1 dmesg: highlight -T issues in docs
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-08-25 15:43:03 +02:00
Karel Zak 5a34fb8a07 dmesg: use GMT in tests, add DMESG_TEST_BOOTIME
We don't want to hardcode anything to the test, just use
env.variable DMESG_TEST_BOOTIME.

Signed-off-by: Karel Zak <kzak@redhat.com>
2015-03-23 11:40:59 +01:00
Sami Kerola 5fac518cef tests: add test_dmesg that has fixed boot time
This allows testing time stamp formats.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2015-03-23 10:34:49 +01:00
Sami Kerola f1300e2cea dmesg: fix shadow declaration
sys-utils/dmesg.c:650:9: warning: declaration of 's' shadows a previous local [-Wshadow]
sys-utils/dmesg.c:619:12: warning: shadowed declaration is here [-Wshadow]

And since the code had to be touched deprecate loop printing one character
at a time, in favour of printf and instruction to repeat spaces the number
required.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2015-03-23 10:34:49 +01:00
Karel Zak 5d51dc2a7f colors: cleanup man pages, add hint to usage()
cfdisk, fdisk, calm dmesg and hexdump

Signed-off-by: Karel Zak <kzak@redhat.com>

Signed-off-by: Karel Zak <kzak@redhat.com>
2015-02-25 12:40:06 +01:00
Benno Schulenberg fc14ceba5e textual: grammarize and harmonize the stat error message
The message "stat failed %s" seems to say that stat() failed to
do something, or failed to pass a test, but of course it means
that the statting of something failed.  So say so.  Also make
two very similar messages equal to this one.

Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
2015-02-02 11:27:10 +01:00
Ingo Brückl b45c3da2e1 dmesg: Enable proper indent for messages containing line breaks
Messages containing line breaks somehow look broken when additional time,
facility or level information is displayed, because they partly appear in
time/facility/level column.

Indent them accordingly.

Signed-off-by: Karel Zak <kzak@redhat.com>
2015-01-26 11:03:34 +01: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 cd2876d252 build-sys: move all around clock_gettime() to monotonic.c
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-11-19 11:54:47 +01:00
Karel Zak 33ecab2b9c dmesg: improve reltime colors
[  +0.004034] sd 113:0:0:0: [sdb] Attached SCSI disk
[Oct10 13:04]  sdb: unknown partition table
[  +0.034011]  sdb: sdb1 sdb2 sdb3 sdb4 < sdb5 sdb6 >

.. the "Oct10 13:04" is possible to colorize by "timebreak"
scheme (default is bold green).

Signed-off-by: Karel Zak <kzak@redhat.com>
2014-10-14 10:20:19 +02:00
Sami Kerola f627750083 textual: use version printing macro everywhere
Only mount, umount, and blkid remains not using the macro because they
are print also library references.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2014-10-01 12:33:23 +02:00
Benno Schulenberg 6269814950 textual: grammarize an error message
Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
2014-10-01 09:37:07 +02:00
Sami Kerola d9bdd89db1 dmesg: avoid unnecessary variable assignment
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2014-07-13 18:35:38 +01:00
Karel Zak f4bc7f96a6 dmesg: support colors customization
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-05-13 12:13:02 +02:00
Karel Zak 08ca3e26a8 lib/timeutils: remove get_boot_time from libcommon
clock_gettime() needs -lrt, so let's keep this stuff
outside libcommon.la

Reported-by: Ruediger Meier <sweet_f_a@gmx.de>
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-05-06 13:16:05 +02:00
Karel Zak d12d063b4a dmesg: add missing include
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-05-06 10:28:26 +02:00
Sami Kerola 929f939e6a dmesg: move get_boot_time() to lib/timeutils
In future the last(1) will use get_boot_time() as well.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2014-05-04 11:42:03 +01:00
Karel Zak 885717c63e Revert "dmesg: don't use brow/yellow in output"
It will be better to support colors customization than use
ugly blue color. BTW, for example git-log uses brow/yellow too
by default.

This reverts commit 0b6fbc2599.
2014-04-23 11:09:44 +02:00
Karel Zak 0b6fbc2599 dmesg: don't use brow/yellow in output
The color used for subsystem prefix is useless on
while background. Let's use blue.

Signed-off-by: Karel Zak <kzak@redhat.com>
2014-04-01 14:32:38 +02:00
Karel Zak 97c3278925 dmesg: don't report EPIPE
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-03-13 12:39:09 +01:00
Ondrej Oprala d0c9ddc3cc lib/colors: check for /etc/terminal-colors.d/[util].disable
[kzak@redhat.com: - move paths to pathnames.h,
                  - use static path buffer]

Signed-off-by: Ondrej Oprala <ooprala@redhat.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-03-11 09:38:09 +01:00
Karel Zak 3938c08cd5 dmesg: -w output not line-buffered
when writing to e.g. a pipe, output from dmesg -w can come many
minutes late due to buffering.

Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1060925
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-02-06 11:48:40 +01:00
Karel Zak 1a38ad5c32 dmesg: fix --raw zero timestamp for kmsg
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1049438
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-01-07 17:41:42 +01:00
Benno Schulenberg 4df288452e textual: properly use uppercase in certain abbreviations
Reported-by: Petr Písař <petr.pisar@atlas.cz>
Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
2013-10-08 15:27:28 +02:00
Karel Zak 5042cdcf77 dmesg: don't use pager for --follow
References: https://bugzilla.redhat.com/show_bug.cgi?id=984666
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-07-29 13:51:35 +02:00
Sami Kerola e7ba987a04 dmesg: inform user --show-delta and iso8601 time format does not mix
References: http://marc.info/?l=util-linux-ng&m=137267606929951&w=2
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2013-07-09 14:24:53 +02:00
Sami Kerola 3c5384d05d dmesg: make time stamps to be printed consistently
Earlier uptime determination, which was done with sysinfo(2), had one
second resolution, which made time stamps to be rounded unstable way
depending on when a dmesg command was executed.  In practical terms; the
command below was supposed not to differ but it did.

$ diff -q <(dmesg --ctime) <(sleep 0.5 ; dmesg --ctime)

[kzak@redhat.com: - add -lrt to Makemodule.am,
                  - fallback to sysinfo() based boot time
                  - use #ifdef]

CC: Kay Sievers <kay@vrfy.org>
References: https://lkml.org/lkml/2013/6/30/37
Buglink: https://github.com/karelzak/util-linux/issues/24
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-07-01 14:30:20 +02:00
Karel Zak 15a1e37168 dmesg: define is_timefmt() macro only once
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-07-01 11:29:06 +02:00
Karel Zak 81bd88e4f3 dmesg: fix --human color initialization
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-07-01 11:17:17 +02:00
Sami Kerola 06dd56f91c dmesg: regroup time related options close to each other
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2013-07-01 11:07:48 +02:00
Sami Kerola 8a8be309d4 dmesg: add iso-8601 time format
The ISO-8601 should be welcomed by anyone who tries to parse dmesg time
stamp, and compare them across servers.  Time format tries to imitate
coreutils 'date --iso-8601=ns' output, but instead of having nanoseconds
the dmesg is using microseconds.

Reference: http://www.cs.tut.fi/~jkorpela/iso8601.html
Addresses: http://xkcd.com/1179/
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2013-07-01 11:07:39 +02:00
Sami Kerola babf605d2c dmesg: add --time-format option
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2013-07-01 11:07:37 +02:00
Sami Kerola 776eabe751 dmesg: convert time format bitfield to enum
Foremost this commit makes time printing formats explicit.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2013-07-01 11:07:35 +02:00
Karel Zak b7faf99128 lib/colors: add colormode_or_err()
... to make the code easy to use in utils.

Signed-off-by: Karel Zak <kzak@redhat.com>
2013-05-07 09:09:35 +02:00
Sami Kerola 30b44cf1e7 dmesg: fix usage() typo
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2013-05-06 19:26:58 +02:00
Karel Zak 9bc2b51a06 dmesg: support --color[={auto,always,never}]
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-05-06 19:11:28 +02:00
Andrii Bordunov 6a5e45180b dmesg: minor cleanup of EXCL_xxx_ERR macros
Delete EXCL_ACT_ERR and EXCL_SYS_ERR defines:
usage is removed in 43d2eeef5dd3a64c372dbf60e4a32aa9e97b4645:
    "dmesg: use err_exclusive_options()"

Signed-off-by: Karel Zak <kzak@redhat.com>
2013-04-23 14:40:47 +02:00
Sami Kerola 963ac50734 dmesg: fix usage() output consistancy
Possible facilities and levels are meant to be printed to same file as
the rest of the usage output.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2013-04-05 13:55:57 +02:00
Karel Zak aa192520d3 dmesg: use $PAGER for --human output, add --nopager
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-03-18 14:05:24 +01:00
Karel Zak f0a3a1caac dmesg: add --human
* enable --reltime
 * enable --color
 * a little bit cleanup main()

Signed-off-by: Karel Zak <kzak@redhat.com>
2013-03-18 12:38:28 +01:00
Karel Zak 5aaee63cdf dmesg: more colors, more fun
* colorize subsystem prefix
 * colorize time
 * colorize by keywords (now "segfault" only)

Signed-off-by: Karel Zak <kzak@redhat.com>
2013-03-18 12:28:32 +01:00
Karel Zak 0a86a1a66c dmesg: fix usage() 2013-01-30 15:36:21 +01:00
Sami Kerola fbbc4c88d5 dmesg: make usage() translator friendly
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2013-01-25 16:40:05 +01:00
Sami Kerola bb9013177c dmesg: parse level when --color is used
When user runs with --color it should not need to be combined with
filtering per level or facility, or decoding.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2013-01-25 10:29:37 +01:00
Sami Kerola ae6288da84 dmesg: add boundary check to facility & level array usage
The dmesg should not crash while --decode'ing message facilities and
levels to readable string even if the values are out of bounds.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2013-01-25 10:09:36 +01:00
Ondrej Oprala 098ce273ca dmesg: Add a --color option to colorize error and panic messages
[kzak@redhat.com: - update man page
                  - colorize critical messages too]

Signed-off-by: Karel Zak <kzak@redhat.com>
Signed-off-by: Ondrej Oprala <ooprala@redhat.com>
2012-10-16 16:42:32 +02:00
Bjørn Mork 8c8fa302c1 dmesg: fix console-level off-by-one
commit f06ec64f dmesg; support level names (e.g. --console-level=alert)

introduced an off-by-one error.  The kernel will print messages with
a *higher* level than the console-level. The bug made it impossible to
set the level for debugging, like it is documented in e.g
Documentation/networking/netconsole.txt :

 nemi:/tmp# dmesg -n 8
 dmesg: unknown level '8'

And attempting to set the "emerg" level would result in an invalid 0 value:

 nemi:/tmp# dmesg -n emerg
 dmesg: klogctl failed: Invalid argument

Restoring the old behaviour for numeric levels, and mapping the level
names so that "dmesg -n debug" behaves as expected: logging everything
at level "debug" and higher.

[kzak@redhat.com: - add comment to parse_level()]

Signed-off-by: Bjørn Mork <bjorn@mork.no>
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-10-02 11:43:10 +02:00
Milan Broz 4ceb601d21 dmesg: fix kmsg read if read returns EPIPE
The /dev/kmsg can return EPIPE if current record has beed modified
while reading.

For init_kmsg, it cause switch to DMESG_METHOD_SYSLOG
(which is not expected) and later it can truncate output.

Signed-off-by: Milan Broz <mbroz@redhat.com>
2012-08-13 15:54:57 +02:00
Karel Zak 298a073c2a dmesg: fix kmsg usability detection
On old kernels (<3.5) kernel allows to open read-only /dev/kmsg for
root, but read() returns -EINVAL. It means that open() is not enough
to detect /dev/kmsg usability. We have to call read() (or epoll).

Reported-by: Kay Sievers <kay.sievers@vrfy.org>
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-08-02 17:39:14 +02:00