[RFC 2/9] printk: Bring back printk_emit

Tony Asleson
2019-12-23T22:56:10Z

Needed for adding structured logging in a number of different areas.

Signed-off-by: Tony Asleson <tasleson@redhat.com>
---
include/linux/printk.h | 5 +++++
kernel/printk/printk.c | 15 +++++++++++++++
2 files changed, 20 insertions(+)

diff --git a/include/linux/printk.h b/include/linux/printk.h
index c09d67edda3a..06c3ba5b695e 100644
--- a/include/linux/printk.h
+++ b/include/linux/printk.h
@@ -167,6 +167,11 @@ int vprintk_emit(int facility, int level,
asmlinkage __printf(1, 0)
int vprintk(const char *fmt, va_list args);

+asmlinkage __printf(5, 6) __cold
+int printk_emit(int facility, int level,
+ const char *dict, size_t dictlen,
+ const char *fmt, ...);
+
asmlinkage __printf(1, 2) __cold
int printk(const char *fmt, ...);

diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c
index ca65327a6de8..8d7be8c9bb08 100644
--- a/kernel/printk/printk.c
+++ b/kernel/printk/printk.c
@@ -2009,6 +2009,21 @@ asmlinkage int vprintk(const char *fmt, va_list args)
}
EXPORT_SYMBOL(vprintk);

+asmlinkage int printk_emit(int facility, int level,
+ const char *dict, size_t dictlen,
+ const char *fmt, ...)
+{
+ va_list args;
+ int r;
+
+ va_start(args, fmt);
+ r = vprintk_emit(facility, level, dict, dictlen, fmt, args);
+ va_end(args);
+
+ return r;
+}
+EXPORT_SYMBOL(printk_emit);
+
int vprintk_default(const char *fmt, va_list args)
{
int r;
--
2.21.0