summaryrefslogtreecommitdiffstats
path: root/sys-utils/dmesg.c
Commit message (Collapse)AuthorAgeFilesLines
* dmesg: fix output hex encodingKarel Zak2019-08-011-11/+15
| | | | | | | The current code ignores single-byte non-printable characters. Reported-by: Marc Deslauriers <marc.deslauriers@canonical.com> Signed-off-by: Karel Zak <kzak@redhat.com>
* dmesg: make strtok() use more robustKarel Zak2019-05-231-0/+3
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* misc: consolidate version printing and close_stdout()Karel Zak2019-04-161-7/+6Star
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* dmesg: fix raw outputKarel Zak2018-04-051-2/+1Star
| | | | | | | | | The commit 5f538ac40c0d215b6c9a881effe4c3b214366715 has introduced regression ("goto" to the wrong place, so timestamps in raw mode is not printed at all). Addresses: https://github.com/karelzak/util-linux/issues/614 Signed-off-by: Karel Zak <kzak@redhat.com>
* misc: fix typos using codespellRuediger Meier2018-02-161-1/+1
| | | | | | Some more funny typos, please review carefully. Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
* dmesg: use xstrdup() in xalloc.h based utilKarel Zak2018-02-131-1/+1
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* dmesg: fix compiler warning [-Wuninitialized]Karel Zak2017-11-281-1/+1
| | | | | | | sys-utils/dmesg.c: In function ‘print_record.constprop.12’: sys-utils/dmesg.c:1039:14: warning: ‘mesg_size’ may be used uninitialized in this function [-Wuninitialized] Signed-off-by: Karel Zak <kzak@redhat.com>
* lib/timeutils: add common ISO timestamp masksJ William Piggott2017-11-101-3/+1Star
| | | | | | | | | | | | | | | | | | | | | | * Start the ISO format flags at bit 0 instead of bit 1. * Remove unnecessary _8601 from ISO format flag names to avoid line wrapping and to ease readability. * ISO timestamps have date-time-timzone in common, so move the TIMEZONE flag to bit 2 causing all timestamp masks to have the first three bits set and the last four bits as timestamp 'options'. * Change the 'SPACE' flag to a 'T' flag, because it makes the code and comments more concise. * Add common ISO timestamp masks. * Implement the ISO timestamp masks in all applicable code using the strxxx_iso() functions. Signed-off-by: J William Piggott <elseifthen@gmx.com>
* dmesg: Add --force-prefix optionPrarit Bhargava2017-11-011-60/+148
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The kernel outputs multi-line messages (kernel messages that contain the end-of-line character '\n'). These message are currently displayed by dmesg as [965199.028940] runnable tasks: task PID tree-key switches prio wait-time sum-exec sum-sleep ---------------------------------------------------------------------------------------------------------- The kernel timestamps each of these lines with [965199.028940] and the dmesg utility should do the same. Add the 'force-prefix'/'-p' dmesg option to add decode & timestamp information to each line of a multi-line message. Notes: The new print_record() algorithm stores the decode & timestamp information in buffers. If the force-prefix option is used, the message is split into separate lines and each line is prefixed with the stored decode & timestamp information. The splitting of the message into separate lines is done using strtok() which requires write access to the message buffer (ie, the const message buffer is now copied into a writeable buffer). Successfully tested by me by looking at sysrq-t and sysrq-w output. All known good /tests passed with these changes. [kzak@redhat.com: - use snprintf() - cleanup \n usage (don't count line break to the message text in the parsers and always print \n after the text - add the option to the man page - use --force-prefix for kmsg only, old syslog(2) API splits messages itself - strdup() the message text only on force-prefix] Signed-off-by: Prarit Bhargava <prarit@redhat.com> Signed-off-by: Karel Zak <kzak@redhat.com>
* Revert "dmesg: fragment concatenation"Karel Zak2017-10-301-110/+7Star
| | | | | | | * introduces regressions * stupid code; parse_kmsg_record() called more than once for each record This reverts commit 22eb2f0190d8a9850da750641439ccd284ac0bfe.
* dmesg: fix delimiter calculationKarel Zak2017-08-161-1/+1
| | | | | Reported-by: Laszlo Varkonyi <vlsoftsystems@gmail.com> Signed-off-by: Karel Zak <kzak@redhat.com>
* misc: consolidate macro style USAGE_HELP_OPTIONSRuediger Meier2017-06-291-2/+2
| | | | | | | | | 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>
* misc: consolidate all --help option descriptionsRuediger Meier2017-06-271-1/+1
| | | | | | | | Now we are always using the same text also for commands which had still hardcoded descriptions or where we can't use the standard print_usage_help_options macro. Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
* misc: introduce print_usage_help_options()Ruediger Meier2017-06-271-2/+1Star
| | | | | | | | | | | | 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>
* misc: never use usage(stderr)Ruediger Meier2017-06-261-5/+8
| | | | | | | Here we fix all cases where we have usage(FILE*) functions. Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
* Merge branch 'usage-part1' of https://github.com/rudimeier/util-linuxKarel Zak2017-06-261-3/+1Star
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | * 'usage-part1' of https://github.com/rudimeier/util-linux: misc: no more errtryh() mkfs.cramfs: add --help and --version more: add --help and --version whereis: add --help and --version login: add --help and --version fsck: add --help and --version setarch: use errtryhelp() dmesg: do not accept any non-option arguments blkid: use errtryhelp instead of errtryh misc: remove superfluous null pointer checks for optarg uuidd: remove unused define
| * dmesg: do not accept any non-option argumentsRuediger Meier2017-06-221-3/+1Star
| | | | | | | | | | | | | | 'dmesg foo' is no valid syntax and gives an error now. BTW we avoid the "dead increment of argc and argv. Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
* | dmesg: print only 2 hex digits for each hex-escaped byteIvan Delalande2017-06-221-1/+1
|/ | | | | | | | | | As buf is passed as a signed char buffer in fwrite_hex, fprintf will print every byte from 0x80 as a signed-extended int causing each of these bytes to be printed as "\xffffff80" and such, which can be pretty confusing. Force fprintf to use the argument as a char to make it print only 2 digits, e.g. "\x80". Signed-off-by: Ivan Delalande <colona@arista.com>
* dmesg: fragment concatenationVinnie Magro2017-06-201-7/+110
| | | | | | | | | | | | | | | | | | When extended console is enabled, the kernel doesn't internally concatenate message fragments, this change adds log fragment concatenation to dmesg: instead of being printed as separate messages, fragments are combined onto one line and printed with the timestamp of the first line. This doesn't work in all cases - such as if another message is logged in between two fragment lines, but in this case the behavior matches the previous output format (printed on the separate lines). [kzak@redhat.com: - rename kmsg_read_buf to kmsg_saved_size, - minor coding style fixes] Signed-off-by: Vinnie Magro <vmagro@fb.com> Signed-off-by: Karel Zak <kzak@redhat.com>
* dmesg: remove unnecessary headerKarel Zak2017-05-311-1/+0Star
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* docs: Fix word repetitionsYuri Chornoivan2017-02-131-1/+1
|
* Use --help suggestion on invalid optionKarel Zak2016-12-191-2/+1Star
| | | | | | | | 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>
* misc: fix unsigned int usage for ctype.h functionsKarel Zak2016-10-261-2/+2
| | | | | Reported-by: "Yuriy M. Kaminskiy" <yumkam@gmail.com> Signed-off-by: Karel Zak <kzak@redhat.com>
* lib/pager: cleanup and extend APIKarel Zak2016-08-261-2/+2
| | | | | | | | | * clean up function names * add functions to temporary redirect to the pager and then restore original terminal output Signed-off-by: Karel Zak <kzak@redhat.com>
* misc: fix declarations shadowing variables in the global scope [oclint]Sami Kerola2016-07-211-7/+7
| | | | | | Fixes multiple occurences of 'optarg' overwrites. Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* dmesg: drop core at impossible case in read_buffer() [oclint]Sami Kerola2016-07-211-0/+2
| | | | Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* misc: simplify if clauses [oclint]Sami Kerola2016-07-211-8/+5Star
| | | | Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* misc: Fix various typosSebastian Rasmussen2016-05-311-5/+5
| | | | | | | Fix various typos in error messages, warnings, debug strings, comments and names of static functions. Signed-off-by: Sebastian Rasmussen <sebras@gmail.com>
* dmesg: fix indentionKarel Zak2016-05-241-1/+1
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* dmesg: use strtimeval_iso()Karel Zak2016-05-241-13/+12Star
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* dmesg: --notime should not suppress --show-deltaSami Kerola2016-04-171-1/+0Star
| | | | | | | | | | | | | | | The --show-delta is off by default, which means it can be only on when user has requested to see these time stamps. The --notime option should not turn the delta outputing off, because then option order matters and no-one wants that. Example of the old output: $ dmesg --notime --show-delta | sed -n 's/ version.*//p; q' [< 0.000000>] Linux $ dmesg --show-delta --notime | sed -n 's/ version.*//p; q' Linux Addresses: https://bugs.launchpad.net/bugs/1544595 Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* dmesg: improve grammar and consistency of usage textBenno Schulenberg2016-03-161-3/+3
| | | | Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
* misc: always cast timeval.tv_usec to long rather than intRuediger Meier2016-02-121-7/+8
| | | | Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
* dmesg: highlight -T issues in docsKarel Zak2015-08-251-1/+1
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* dmesg: use GMT in tests, add DMESG_TEST_BOOTIMEKarel Zak2015-03-231-7/+19
| | | | | | | 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>
* tests: add test_dmesg that has fixed boot timeSami Kerola2015-03-231-0/+5
| | | | | | This allows testing time stamp formats. Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* dmesg: fix shadow declarationSami Kerola2015-03-231-8/+3Star
| | | | | | | | | | | 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>
* colors: cleanup man pages, add hint to usage()Karel Zak2015-02-251-0/+2
| | | | | | | | cfdisk, fdisk, calm dmesg and hexdump Signed-off-by: Karel Zak <kzak@redhat.com> Signed-off-by: Karel Zak <kzak@redhat.com>
* textual: grammarize and harmonize the stat error messageBenno Schulenberg2015-02-021-1/+1
| | | | | | | | | 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>
* dmesg: Enable proper indent for messages containing line breaksIngo Brückl2015-01-261-24/+40
| | | | | | | | | | 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>
* textual: add a docstring to most of the utilitiesBenno Schulenberg2015-01-061-0/+4
| | | | | | | | | 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>
* build-sys: move all around clock_gettime() to monotonic.cKarel Zak2014-11-191-1/+1
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* dmesg: improve reltime colorsKarel Zak2014-10-141-0/+3
| | | | | | | | | | | [ +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>
* textual: use version printing macro everywhereSami Kerola2014-10-011-2/+1Star
| | | | | | | 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>
* textual: grammarize an error messageBenno Schulenberg2014-10-011-2/+2
| | | | Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
* dmesg: avoid unnecessary variable assignmentSami Kerola2014-07-131-1/+2
| | | | Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* dmesg: support colors customizationKarel Zak2014-05-131-24/+47
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* lib/timeutils: remove get_boot_time from libcommonKarel Zak2014-05-061-0/+1
| | | | | | | | 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>
* dmesg: add missing includeKarel Zak2014-05-061-0/+1
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* dmesg: move get_boot_time() to lib/timeutilsSami Kerola2014-05-041-27/+0Star
| | | | | | In future the last(1) will use get_boot_time() as well. Signed-off-by: Sami Kerola <kerolasa@iki.fi>