diff options
Diffstat (limited to 'libbcachefs/util.c')
-rw-r--r-- | libbcachefs/util.c | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/libbcachefs/util.c b/libbcachefs/util.c index 42da6623..81befc43 100644 --- a/libbcachefs/util.c +++ b/libbcachefs/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> @@ -274,6 +275,27 @@ 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; + prefix = KERN_CONT; + } + console_unlock(); +} + /* time stats: */ static void bch2_time_stats_update_one(struct time_stats *stats, |