Commit Graph

46 Commits

Author SHA1 Message Date
Petr Uzel 5920295058 dmesg: avoid mess at the end of dmesg output
Since util-linux commit a7ee94f220,
dmesg incorrectly calculates number of bytes that are remaining in the
buffer in get_next_record(). This could, under specific circumstances,
cause printing mess at the end of dmesg output:

> dmesg | tail
[ 1191.478725] Adding 285488k swap on /root/swapfile.  Priority:-2 extents:15 across:1186612k
[ 1205.588331] Adding 285488k swap on /root/swapfile.  Priority:-2 extents:15 across:1186612k
\xffffffba\xffffffba

Reported-by: Glenn Doig <doiggl@velocitynet.com.au>
Addresses: https://bugzilla.novell.com/show_bug.cgi?id=710417

Signed-off-by: Petr Uzel <petr.uzel@suse.cz>
2011-08-15 14:28:21 +02:00
Karel Zak 738767b921 dmesg: fix compiler warnings [-Wsign-compare]
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-08-01 13:01:31 +02:00
Karel Zak 9feec79cc5 misc: use unsigned int for bit-fileds
Reported-by: Sami Kerola <kerolasa@iki.fi>
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-07-29 10:51:06 +02:00
Karel Zak c87638ad30 include: [strutils.c] add list parsers
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-07-27 16:41:21 +02:00
Karel Zak 608d45015f dmesg: allow to print time delta without timestamp
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-07-20 17:03:24 +02:00
Karel Zak 641986cf92 dmesg: mark some options mutually exclusive
Reported-by: "Voelker, Bernhard" <bernhard.voelker@siemens-enterprise.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-07-20 15:50:34 +02:00
Karel Zak 42fac79a21 dmesg: add --ctime to print human readable timestamps
Based on patch from "corentin.labbe" <corentin.labbe@geomatys.fr>.

Signed-off-by: Karel Zak <kzak@redhat.com>
2011-07-20 14:26:45 +02:00
Karel Zak bd304d92ff dmesg: add --show-delta option
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-07-20 12:52:15 +02:00
Karel Zak a7ee94f220 dmesg: print_buffer() refactoring
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-07-19 21:37:34 +02:00
Karel Zak aca1633a3e dmesg: variables refactoring
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-07-19 20:00:54 +02:00
Marc-Antoine Perennou 730d5e7761 dmesg: fix segfault
An element declared as size_t cannot be detected as negative (len < 0)
is always false.
This can lead to an infinite loop causing a segmentation fault.
Check if len is equal to -1 or -2 instead

Signed-off-by: Marc-Antoine Perennou <Marc-Antoine@Perennou.com>
2011-07-18 23:46:45 +02:00
Karel Zak d74b8dfc70 dmesg: add -t option to suppress timestamps
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-07-18 11:48:41 +02:00
Karel Zak 2500018011 dmesg: add -u and -k options
-u  : print kernel messages
 -k  : print userspace message

The options could be mixed together or with --facility option too.

Signed-off-by: Karel Zak <kzak@redhat.com>
2011-07-18 11:28:15 +02:00
Karel Zak 872a1575e8 dmesg: fix typo in usage()
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-07-14 13:46:13 +02:00
Karel Zak 5ef053699b dmesg: reorder options, add comments
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-07-14 13:31:53 +02:00
Karel Zak 0e24df3b10 dmesg: add --facility option
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-07-14 12:48:07 +02:00
Karel Zak 85f3cc55f7 dmesg: add --decode to print readable facility and level
# dmesg --decode
 ...
 kern  :info  : [53335.743185] PM: resume of devices complete after 2496.795 msecs
 kern  :debug : [53335.743593] PM: Finishing wakeup.
 kern  :warn  : [53335.743595] Restarting tasks ... done.
 kern  :info  : [53335.790452] video LNXVIDEO:00: Restoring backlight state
 kern  :debug : [53336.418576] e1000e 0000:00:19.0: irq 45 for MSI/MSI-X

Signed-off-by: Karel Zak <kzak@redhat.com>
2011-07-14 12:30:18 +02:00
Karel Zak 636a6207d9 dmesg: add --level=<list>
For example

	dmesg --level=err,warn

will print only error and warning messages.

Signed-off-by: Karel Zak <kzak@redhat.com>
2011-07-13 15:50:47 +02:00
Karel Zak 5c8f6bc6df dmesg: consolidate level parsiig code
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-07-13 15:06:53 +02:00
Karel Zak b8300c0a1e dmesg: don't print non-printable chars, parse records
All non-printable chars, non-printable multibyte sequences or invalid
multibyte sequences will be replaced with \x<hex> strings.

Signed-off-by: Karel Zak <kzak@redhat.com>
2011-07-13 15:00:49 +02:00
Karel Zak f06ec64fda dmesg; support level names (e.g. --console-level=alert)
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-07-01 16:33:34 +02:00
Karel Zak 2170174ee3 dmesg: add --console-on and --console-off
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-07-01 15:30:16 +02:00
Karel Zak 0506537a10 dmesg: cleanup options and man page
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-07-01 14:56:22 +02:00
Karel Zak 0419986053 dmesg: add --clear (SYSLOG_ACTION_CLEAR)
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-07-01 14:33:27 +02:00
Karel Zak 48c5c66212 dmesg: refactoring - cleanup main() code
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-07-01 14:26:19 +02:00
Karel Zak 65e3eed924 dmesg: refactoring - cleanup read buffer code
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-07-01 14:15:07 +02:00
Karel Zak f4fa5b44df dmesg: refactoring - cleanup print buffer code
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-07-01 13:57:36 +02:00
Karel Zak eed99b2a7c dmesg: refactoring - cleanup get bufsize code
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-07-01 13:49:25 +02:00
Karel Zak 59a1489968 dmesg: use SYSLOG_ACTION_* macros rather than magic constatnts
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-07-01 13:41:56 +02:00
Karel Zak 4a3b794968 dmesg: add long options, --help and --version
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-07-01 13:36:11 +02:00
Marek Polacek 15103c4bc6 dmesg.c: cleanups -- use err(), xalloc()
Signed-off-by: Marek Polacek <mpolacek@redhat.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-02-28 10:10:32 +01:00
Davidlohr Bueso 15673c1598 dmesg: use strtol_or_err instead of atoi
We shouldn't be accepting things like 'dmesg -n 2crapinput'
This patch also changes the exit's value to use EXIT_* constants.

Signed-off-by: Davidlohr Bueso <dave@gnu.org>
2011-02-08 15:40:48 +01:00
Davidlohr Bueso 219da9223d dmesg: fix memory leak in dmesg(1).
Signed-off-by: Davidlohr Bueso <dave@gnu.org>
2010-08-04 11:46:38 +02:00
Karel Zak e6c379eb8d dmesg: add -r to help output
On Tue, Aug 04, 2009 at 05:52:38PM +0200, Dalibor Straka wrote:
> while I was reading the source, I've noticed missing option in the
> help message for "-r". So I'm sending one-line patch for dmesg.

Reported-by: Dalibor Straka <dast@panelnet.cz>
Signed-off-by: Karel Zak <kzak@redhat.com>
2009-08-17 11:37:27 +02:00
Adam Jackson 11ea22d5a3 dmesg: Add -r (raw) option.
Useful for debugging which kernel messages are ruining your quiet
bootup.

Signed-off-by: Adam Jackson <ajax@redhat.com>
2009-01-16 12:34:49 +01:00
maximilian attems 5423ccb1a1 dmesg: nuke old glibc 5 support
dmesg.c:42: error: expected declaration specifiers or ‘...’ before ‘klogctl’
dmesg.c:42: error: expected declaration specifiers or ‘...’ before ‘type’
dmesg.c:42: error: expected declaration specifiers or ‘...’ before ‘b’
dmesg.c:42: error: expected declaration specifiers or ‘...’ before ‘len’

without belows compat section dmesg just compiles fine against klibc.
as bonus reorder the includes.

Signed-off-by: maximilian attems <max@stro.at>
2008-07-28 11:06:50 +02:00
Karel Zak c129767e06 Imported from util-linux-2.12b tarball. 2006-12-07 00:26:16 +01:00
Karel Zak df1dddf9ff Imported from util-linux-2.12 tarball. 2006-12-07 00:26:12 +01:00
Karel Zak ffc4374869 Imported from util-linux-2.11o tarball. 2006-12-07 00:25:53 +01:00
Karel Zak 364cda4857 Imported from util-linux-2.11f tarball. 2006-12-07 00:25:48 +01:00
Karel Zak c07ebfa1e0 Imported from util-linux-2.11b tarball. 2006-12-07 00:25:46 +01:00
Karel Zak 22853e4a82 Imported from util-linux-2.10m tarball. 2006-12-07 00:25:43 +01:00
Karel Zak 7eda085c41 Imported from util-linux-2.9v tarball. 2006-12-07 00:25:39 +01:00
Karel Zak 2b6fc908bc Imported from util-linux-2.8 tarball. 2006-12-07 00:25:35 +01:00
Karel Zak fd6b7a7ffc Imported from util-linux-2.7.1 tarball. 2006-12-07 00:25:34 +01:00
Karel Zak 6dbe3af945 Imported from util-linux-2.2 tarball. 2006-12-07 00:25:32 +01:00