busybox: squashed commit of merging cm-12.1
With fixes to LOCAL_C_INCLUDES for libsepol in M and fixed
some missing includes to enable building for 64 bit devices
Conflicts:
Android.mk
android/libc/arch-x86/syscalls/swapoff.S
android/libc/arch-x86/syscalls/swapon.S
android/libc/arch-x86/syscalls/sysinfo.S
android/librpc/pmap_rmt.c
android/reboot.c
include-full/copy-current.sh
include-minimal/copy-current.sh
include/platform.h
networking/interface.c
networking/nslookup.c
Change-Id: If6092fa87f3d21190db1af4f70daa150eb462660
diff --git a/util-linux/dmesg.c b/util-linux/dmesg.c
index 84173ce..ba52036 100644
--- a/util-linux/dmesg.c
+++ b/util-linux/dmesg.c
@@ -10,23 +10,37 @@
*/
//usage:#define dmesg_trivial_usage
-//usage: "[-c] [-n LEVEL] [-r] [-s SIZE] [-C]"
+//usage: "[-c] [-n LEVEL] [-s SIZE]"
+//usage: IF_FEATURE_DMESG_PRETTY(" [-r]")
+//usage: IF_FEATURE_DMESG_COLOR(" [-C]")
//usage:#define dmesg_full_usage "\n\n"
//usage: "Print or control the kernel ring buffer\n"
//usage: "\n -c Clear ring buffer after printing"
//usage: "\n -n LEVEL Set console logging level"
-//usage: "\n -r Show level prefix"
//usage: "\n -s SIZE Buffer size"
-//usage: "\n -C Colored output"
+//usage: IF_FEATURE_DMESG_PRETTY(
+//usage: "\n -r Show level prefix")
+//usage: IF_FEATURE_DMESG_COLOR(
+//usage: "\n -C Colored output")
#include <sys/klog.h>
#include "libbb.h"
+#if ENABLE_FEATURE_DMESG_COLOR
#define COLOR_DEFAULT 0
-#define COLOR_WHITE 231
-#define COLOR_YELLOW 226
-#define COLOR_ORANGE 166
-#define COLOR_RED 196
+#define COLOR_WHITE 97
+#define COLOR_YELLOW 93
+#define COLOR_ORANGE 33
+#define COLOR_RED 91
+
+static void set_color(int color)
+{
+ printf("%c[%dm", 0x1B, color);
+}
+
+#else
+#define set_color(c) {}
+#endif
int dmesg_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
int dmesg_main(int argc UNUSED_PARAM, char **argv)
@@ -34,12 +48,14 @@
int len, level;
char *buf;
unsigned opts;
+ int color = 0;
enum {
OPT_c = 1 << 0,
OPT_s = 1 << 1,
OPT_n = 1 << 2,
OPT_r = 1 << 3,
- OPT_C = 1 << 4
+ OPT_C = 1 << 4,
+ OPT_end
};
opt_complementary = "s+:n+"; /* numeric */
@@ -67,14 +83,15 @@
if ((ENABLE_FEATURE_DMESG_PRETTY || (opts & OPT_C)) && !(opts & OPT_r)) {
int last = '\n';
- int in = 0, l, color;
- char pfx[16], *lvl;
+ int in = 0;
/* Skip <[0-9]+> at the start of lines */
while (1) {
if (last == '\n' && buf[in] == '<') {
+
+#if ENABLE_FEATURE_DMESG_COLOR
if (opts & OPT_C) {
- lvl = buf + in + 1;
+ char *lvl = buf + in + 1;
sscanf(lvl, "%d", &level);
switch (level) {
@@ -84,18 +101,14 @@
case 4: color = COLOR_ORANGE; break;
case 5: color = COLOR_YELLOW; break;
case 7: color = COLOR_WHITE; break;
- case 6: // common dmesg info
- default: color = COLOR_DEFAULT;
+ case 6: /* common dmesg info */
+ default:
+ color = COLOR_DEFAULT;
}
- if (color != COLOR_DEFAULT)
- l = sprintf(pfx, "%c[%d;%d;%dm",
- 0x1B, 38, 5, color);
- else
- l = sprintf(pfx, "%c[%dm", 0x1B, 0);
-
- full_write(STDOUT_FILENO, pfx, l);
+ set_color(color);
}
+#endif
while (buf[in++] != '>' && in < len)
;
} else {
@@ -105,17 +118,9 @@
if (in >= len)
break;
}
-
- if (opts & OPT_C) {
- /* Reset default terminal color */
- l = sprintf(pfx, "%c[%dm", 0x1B, 0);
- full_write(STDOUT_FILENO, pfx, l);
- }
-
/* Make sure we end with a newline */
if (last != '\n')
bb_putchar('\n');
-
} else {
full_write(STDOUT_FILENO, buf, len);
if (buf[len-1] != '\n')
@@ -124,5 +129,9 @@
if (ENABLE_FEATURE_CLEAN_UP) free(buf);
+ /* Reset default terminal color */
+ if (color)
+ set_color(0);
+
return EXIT_SUCCESS;
}