aboutsummaryrefslogtreecommitdiff
path: root/toys
diff options
context:
space:
mode:
authorRob Landley <rob@landley.net>2015-05-03 15:13:41 -0500
committerRob Landley <rob@landley.net>2015-05-03 15:13:41 -0500
commitfcd2729305888d0d8e4af2e6d158b9bbb97541af (patch)
treecd160dc4ee5ef9c9345914727ea82c4ad0e1b75e /toys
parent5640acb50da707b404e00e9a20ba3fb3ec334a91 (diff)
downloadtoybox-fcd2729305888d0d8e4af2e6d158b9bbb97541af.tar.gz
Minor dmesg cleanup.
Diffstat (limited to 'toys')
-rw-r--r--toys/lsb/dmesg.c21
1 files changed, 6 insertions, 15 deletions
diff --git a/toys/lsb/dmesg.c b/toys/lsb/dmesg.c
index 50da8a8a..aac638d0 100644
--- a/toys/lsb/dmesg.c
+++ b/toys/lsb/dmesg.c
@@ -5,13 +5,13 @@
* http://refspecs.linuxfoundation.org/LSB_4.1.0/LSB-Core-generic/LSB-Core-generic/dmesg.html
// We care that FLAG_c is 1, so keep c at the end.
-USE_DMESG(NEWTOY(dmesg, "trs#<1n#c", TOYFLAG_BIN))
+USE_DMESG(NEWTOY(dmesg, "trs#<1n#c[!tr]", TOYFLAG_BIN))
config DMESG
bool "dmesg"
default y
help
- usage: dmesg [-n LEVEL] [-s SIZE] [-r|-t] | -c
+ usage: dmesg [-c] [-r|-t] [-n LEVEL] [-s SIZE]
Print or control the kernel ring buffer.
@@ -33,9 +33,6 @@ GLOBALS(
void dmesg_main(void)
{
- if ((toys.optflags & FLAG_r) && (toys.optflags & FLAG_t)) {
- error_exit("dmesg: -r and -t are mutually exclusive options");
- }
// For -n just tell kernel to which messages to keep.
if (toys.optflags & FLAG_n) {
if (klogctl(8, NULL, TT.level)) perror_exit("klogctl");
@@ -54,17 +51,11 @@ void dmesg_main(void)
// Filter out level markers and optionally time markers
if (!(toys.optflags & FLAG_r)) while ((from - data) < size) {
if (from == data || from[-1] == '\n') {
- if (*from == '<') {
- int i = stridx(from, '>');
-
- if (i>0) from += i+1;
- }
- if ((*from == '[') && (toys.optflags & FLAG_t)) {
- int i = stridx(from, ']');
+ char *to;
- if (i>0) from += i+1;
- if (*from == ' ') ++from;
- }
+ if (*from == '<' && (to = strchr(from, '>'))) from = ++to;
+ if ((toys.optflags&FLAG_t) && *from == '[' && (to = strchr(from, ']')))
+ from = to+1+(to[1]==' ');
}
*(to++) = *(from++);
} else to = data+size;