summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEugene Syromyatnikov <evgsyr@gmail.com>2018-09-27 07:17:27 +0200
committerDmitry V. Levin <ldv@altlinux.org>2019-08-05 22:48:31 +0000
commit489690a120903fb5256a66c56c057e4187559e6c (patch)
tree2a94b98d4095402f158ce73b9a59d3799e085c1c
parent43946df838529fb810cc203411defdadefb242db (diff)
downloadstrace-489690a120903fb5256a66c56c057e4187559e6c.tar.gz
syslog: decode log level in SYSLOG_ACTION_CONSOLE_LEVEL command
* xlat/syslog_console_levels.in: New file. * syslog.c: Include "xlat/syslog_console_levels.h". (SYS_FUNC(syslog)): Add SYSLOG_ACTION_CONSOLE_LEVEL case. * tests/syslog.c: Add checks.
-rw-r--r--syslog.c10
-rw-r--r--tests/syslog.c16
-rw-r--r--xlat/syslog_console_levels.in11
3 files changed, 37 insertions, 0 deletions
diff --git a/syslog.c b/syslog.c
index 1297f7f14..b5e0d8f34 100644
--- a/syslog.c
+++ b/syslog.c
@@ -9,6 +9,7 @@
#include "defs.h"
#include "xlat/syslog_action_type.h"
+#include "xlat/syslog_console_levels.h"
SYS_FUNC(syslog)
{
@@ -40,6 +41,15 @@ SYS_FUNC(syslog)
return 0;
}
break;
+
+ case SYSLOG_ACTION_CONSOLE_LEVEL: /* Uses len */
+ tprints(", ");
+ printaddr64(tcp->u_arg[1]);
+ tprints(", ");
+ printxval_ex(syslog_console_levels, len, "LOGLEVEL_???",
+ XLAT_STYLE_VERBOSE | XLAT_STYLE_FMT_D);
+ return RVAL_DECODED;
+
default:
tprints(", ");
printaddr64(tcp->u_arg[1]);
diff --git a/tests/syslog.c b/tests/syslog.c
index a3c66e8d7..a3417ea21 100644
--- a/tests/syslog.c
+++ b/tests/syslog.c
@@ -58,6 +58,15 @@ main(void)
{ 11, "11 /* SYSLOG_ACTION_??? */" },
{ (1U << 31) - 1, "2147483647 /* SYSLOG_ACTION_??? */" },
};
+ static const struct cmd_str levels[] = {
+ { 0xfeedbeef, "-17973521 /* LOGLEVEL_??? */" },
+ { -1U, "-1 /* LOGLEVEL_??? */" },
+ { 0, "0 /* LOGLEVEL_EMERG */" },
+ { 7, "7 /* LOGLEVEL_DEBUG */" },
+ { 8, "8 /* LOGLEVEL_DEBUG+1 */" },
+ { 9, "9 /* LOGLEVEL_??? */" },
+ { (1U << 31) - 1, "2147483647 /* LOGLEVEL_??? */" },
+ };
static const kernel_ulong_t high =
(kernel_ulong_t) 0xbadc0ded00000000ULL;
const kernel_ulong_t addr = (kernel_ulong_t) 0xfacefeeddeadbeefULL;
@@ -90,6 +99,13 @@ main(void)
sprintrc(rc));
}
+ for (size_t i = 0; i < ARRAY_SIZE(levels); i++) {
+ rc = syscall(__NR_syslog, high | 8, addr, levels[i].cmd);
+ printf("syslog(8 /* SYSLOG_ACTION_CONSOLE_LEVEL */, %#llx, %s)"
+ " = %s\n",
+ (unsigned long long) addr, levels[i].str, sprintrc(rc));
+ }
+
puts("+++ exited with 0 +++");
return 0;
}
diff --git a/xlat/syslog_console_levels.in b/xlat/syslog_console_levels.in
new file mode 100644
index 000000000..9309658e5
--- /dev/null
+++ b/xlat/syslog_console_levels.in
@@ -0,0 +1,11 @@
+#value_indexed
+/* from include/linux/kern_levels.h */
+LOGLEVEL_EMERG 0
+LOGLEVEL_ALERT 1
+LOGLEVEL_CRIT 2
+LOGLEVEL_ERR 3
+LOGLEVEL_WARNING 4
+LOGLEVEL_NOTICE 5
+LOGLEVEL_INFO 6
+LOGLEVEL_DEBUG 7
+LOGLEVEL_DEBUG+1 7