aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--util-linux/dmesg.c15
1 files changed, 10 insertions, 5 deletions
diff --git a/util-linux/dmesg.c b/util-linux/dmesg.c
index 9e834ffd3..b399ab247 100644
--- a/util-linux/dmesg.c
+++ b/util-linux/dmesg.c
@@ -6,7 +6,7 @@
6 * Copyright 2006 Rob Landley <rob@landley.net> 6 * Copyright 2006 Rob Landley <rob@landley.net>
7 * Copyright 2006 Bernhard Fischer <rep.nop@aon.at> 7 * Copyright 2006 Bernhard Fischer <rep.nop@aon.at>
8 * 8 *
9 * Licensed under GPLv2, see file LICENSE in this tarball for details. 9 * Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
10 */ 10 */
11 11
12#include <sys/klog.h> 12#include <sys/klog.h>
@@ -18,17 +18,22 @@ int dmesg_main(int argc ATTRIBUTE_UNUSED, char **argv)
18 int len; 18 int len;
19 char *buf; 19 char *buf;
20 char *size, *level; 20 char *size, *level;
21 int flags = getopt32(argv, "cs:n:", &size, &level); 21 unsigned flags = getopt32(argv, "cs:n:", &size, &level);
22 enum {
23 OPT_c = 1<<0,
24 OPT_s = 1<<1,
25 OPT_n = 1<<2
26 };
22 27
23 if (flags & 4) { 28 if (flags & OPT_n) {
24 if (klogctl(8, NULL, xatoul_range(level, 0, 10))) 29 if (klogctl(8, NULL, xatoul_range(level, 0, 10)))
25 bb_perror_msg_and_die("klogctl"); 30 bb_perror_msg_and_die("klogctl");
26 return EXIT_SUCCESS; 31 return EXIT_SUCCESS;
27 } 32 }
28 33
29 len = (flags & 2) ? xatoul_range(size, 2, INT_MAX) : 16384; 34 len = (flags & OPT_s) ? xatoul_range(size, 2, INT_MAX) : 16384;
30 buf = xmalloc(len); 35 buf = xmalloc(len);
31 len = klogctl(3 + (flags & 1), buf, len); 36 len = klogctl(3 + (flags & OPT_c), buf, len);
32 if (len < 0) 37 if (len < 0)
33 bb_perror_msg_and_die("klogctl"); 38 bb_perror_msg_and_die("klogctl");
34 if (len == 0) 39 if (len == 0)