diff options
author | Kent Overstreet <kent.overstreet@linux.dev> | 2024-03-16 19:36:11 -0400 |
---|---|---|
committer | Kent Overstreet <kent.overstreet@linux.dev> | 2024-03-17 20:53:12 -0400 |
commit | f3589bfa7ee4aff118908e910d05ba96b1858633 (patch) | |
tree | c727d6b75f266c3605e68639e8203424de050145 /fs/bcachefs/super.c | |
parent | 1c31b83a4ec6815cd032b2aeb44785464ba6065b (diff) | |
download | linux-f3589bfa7ee4aff118908e910d05ba96b1858633.tar.gz linux-f3589bfa7ee4aff118908e910d05ba96b1858633.tar.bz2 linux-f3589bfa7ee4aff118908e910d05ba96b1858633.zip |
bcachefs: fix for building in userspace
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
Diffstat (limited to 'fs/bcachefs/super.c')
-rw-r--r-- | fs/bcachefs/super.c | 32 |
1 files changed, 16 insertions, 16 deletions
diff --git a/fs/bcachefs/super.c b/fs/bcachefs/super.c index 233f864ed8b0..1cabdd47e88d 100644 --- a/fs/bcachefs/super.c +++ b/fs/bcachefs/super.c @@ -87,20 +87,27 @@ const char * const bch2_fs_flag_strs[] = { NULL }; -void bch2_print_opts(struct bch_opts *opts, const char *fmt, ...) +static void bch2_print_maybe_redirect(struct stdio_redirect *stdio, const char *fmt, va_list args) { - struct stdio_redirect *stdio = (void *)(unsigned long)opts->stdio; - - va_list args; - va_start(args, fmt); - if (likely(!stdio)) { - vprintk(fmt, args); - } else { +#ifdef __KERNEL__ + if (unlikely(stdio)) { if (fmt[0] == KERN_SOH[0]) fmt += 2; bch2_stdio_redirect_vprintf(stdio, true, fmt, args); + return; } +#endif + vprintk(fmt, args); +} + +void bch2_print_opts(struct bch_opts *opts, const char *fmt, ...) +{ + struct stdio_redirect *stdio = (void *)(unsigned long)opts->stdio; + + va_list args; + va_start(args, fmt); + bch2_print_maybe_redirect(stdio, fmt, args); va_end(args); } @@ -110,14 +117,7 @@ void __bch2_print(struct bch_fs *c, const char *fmt, ...) va_list args; va_start(args, fmt); - if (likely(!stdio)) { - vprintk(fmt, args); - } else { - if (fmt[0] == KERN_SOH[0]) - fmt += 2; - - bch2_stdio_redirect_vprintf(stdio, true, fmt, args); - } + bch2_print_maybe_redirect(stdio, fmt, args); va_end(args); } |