From 09bcb3675701460bfab084162537f107dcd3d9b3 Mon Sep 17 00:00:00 2001 From: Ian Moffett Date: Sat, 17 Feb 2024 22:23:36 -0500 Subject: kernel: syslog: Add '%p' Signed-off-by: Ian Moffett --- sys/kern/kern_syslog.c | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) (limited to 'sys') diff --git a/sys/kern/kern_syslog.c b/sys/kern/kern_syslog.c index 9c87537..52bdcca 100644 --- a/sys/kern/kern_syslog.c +++ b/sys/kern/kern_syslog.c @@ -65,6 +65,8 @@ syslog_handle_fmt(va_list *ap, char fmt_spec) const char *tmp_str; char tmp_buf[256] = { 0 }; + size_t tmp_len; + switch (fmt_spec) { case 'c': tmp_ch = va_arg(*ap, int); @@ -79,10 +81,26 @@ syslog_handle_fmt(va_list *ap, char fmt_spec) itoa(tmp_int, tmp_buf, 10); syslog_write(tmp_buf, strlen(tmp_buf)); break; + case 'p': + tmp_int = va_arg(*ap, uint64_t); + itoa(tmp_int, tmp_buf, 16); + tmp_len = strlen(tmp_buf); + /* + * Now we pad this. + * + * XXX TODO: This assumes 64-bits, should be + * cleaned up. + */ + for (size_t i = 0; i < 18 - tmp_len; ++i) { + syslog_write("0", 1); + } + syslog_write(tmp_buf + 2, tmp_len - 2); + break; case 'x': tmp_int = va_arg(*ap, uint64_t); itoa(tmp_int, tmp_buf, 16); - syslog_write(tmp_buf + 2, strlen(tmp_buf) - 2); + tmp_len = strlen(tmp_buf); + syslog_write(tmp_buf + 2, tmp_len - 2); break; } } -- cgit v1.2.3