diff options
author | Kent Overstreet <kent.overstreet@linux.dev> | 2022-09-25 16:43:55 -0400 |
---|---|---|
committer | Kent Overstreet <kent.overstreet@linux.dev> | 2023-10-22 17:09:41 -0400 |
commit | a8f35428430446d8c9e871b36ab2b49c0a9daec7 (patch) | |
tree | 838e25fc0e019902c1f412de7552a1a6083efd46 /fs/bcachefs/util.c | |
parent | e9174370d0522b466ea770576230b487941101f8 (diff) | |
download | linux-a8f35428430446d8c9e871b36ab2b49c0a9daec7.tar.gz linux-a8f35428430446d8c9e871b36ab2b49c0a9daec7.tar.bz2 linux-a8f35428430446d8c9e871b36ab2b49c0a9daec7.zip |
bcachefs: bch2_print_string_as_lines()
This adds a helper for printing a large buffer one line at a time, to
avoid the 1k printk limit.
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
Diffstat (limited to 'fs/bcachefs/util.c')
-rw-r--r-- | fs/bcachefs/util.c | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/fs/bcachefs/util.c b/fs/bcachefs/util.c index 61cd44c5a6b4..477c260de50b 100644 --- a/fs/bcachefs/util.c +++ b/fs/bcachefs/util.c @@ -8,6 +8,7 @@ #include <linux/bio.h> #include <linux/blkdev.h> +#include <linux/console.h> #include <linux/ctype.h> #include <linux/debugfs.h> #include <linux/freezer.h> @@ -244,6 +245,26 @@ void bch2_prt_u64_binary(struct printbuf *out, u64 v, unsigned nr_bits) prt_char(out, '0' + ((v >> --nr_bits) & 1)); } +void bch2_print_string_as_lines(const char *prefix, const char *lines) +{ + const char *p; + + if (!lines) { + printk("%s (null)\n", prefix); + return; + } + + console_lock(); + while (1) { + p = strchrnul(lines, '\n'); + printk("%s%.*s\n", prefix, (int) (p - lines), lines); + if (!*p) + break; + lines = p + 1; + } + console_unlock(); +} + /* time stats: */ #ifndef CONFIG_BCACHEFS_NO_LATENCY_ACCT |