diff options
author | Florent Revest <revest@chromium.org> | 2021-04-27 20:43:12 +0300 |
---|---|---|
committer | Alexei Starovoitov <ast@kernel.org> | 2021-04-28 01:50:15 +0300 |
commit | 76d6a13383b8e3ff20a9cf52aa9c3de39e485632 (patch) | |
tree | a514ff10079e19e036815347ddca67d30771300e /fs | |
parent | 2551c2d19c04cd1c7b6c99ec04a8ff08193b0ccc (diff) | |
download | linux-76d6a13383b8e3ff20a9cf52aa9c3de39e485632.tar.xz |
seq_file: Add a seq_bprintf function
Similarly to seq_buf_bprintf in lib/seq_buf.c, this function writes a
printf formatted string with arguments provided in a "binary
representation" built by functions such as vbin_printf.
Signed-off-by: Florent Revest <revest@chromium.org>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Link: https://lore.kernel.org/bpf/20210427174313.860948-2-revest@chromium.org
Diffstat (limited to 'fs')
-rw-r--r-- | fs/seq_file.c | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/fs/seq_file.c b/fs/seq_file.c index cb11a34fb871..5059248f2d64 100644 --- a/fs/seq_file.c +++ b/fs/seq_file.c @@ -412,6 +412,24 @@ void seq_printf(struct seq_file *m, const char *f, ...) } EXPORT_SYMBOL(seq_printf); +#ifdef CONFIG_BINARY_PRINTF +void seq_bprintf(struct seq_file *m, const char *f, const u32 *binary) +{ + int len; + + if (m->count < m->size) { + len = bstr_printf(m->buf + m->count, m->size - m->count, f, + binary); + if (m->count + len < m->size) { + m->count += len; + return; + } + } + seq_set_overflow(m); +} +EXPORT_SYMBOL(seq_bprintf); +#endif /* CONFIG_BINARY_PRINTF */ + /** * mangle_path - mangle and copy path to buffer beginning * @s: buffer start |