Skip to content

Commit f3589bf

Browse files
author
Kent Overstreet
committed
bcachefs: fix for building in userspace
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
1 parent 1c31b83 commit f3589bf

File tree

1 file changed

+16
-16
lines changed

1 file changed

+16
-16
lines changed

fs/bcachefs/super.c

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -87,20 +87,27 @@ const char * const bch2_fs_flag_strs[] = {
8787
NULL
8888
};
8989

90-
void bch2_print_opts(struct bch_opts *opts, const char *fmt, ...)
90+
static void bch2_print_maybe_redirect(struct stdio_redirect *stdio, const char *fmt, va_list args)
9191
{
92-
struct stdio_redirect *stdio = (void *)(unsigned long)opts->stdio;
93-
94-
va_list args;
95-
va_start(args, fmt);
96-
if (likely(!stdio)) {
97-
vprintk(fmt, args);
98-
} else {
92+
#ifdef __KERNEL__
93+
if (unlikely(stdio)) {
9994
if (fmt[0] == KERN_SOH[0])
10095
fmt += 2;
10196

10297
bch2_stdio_redirect_vprintf(stdio, true, fmt, args);
98+
return;
10399
}
100+
#endif
101+
vprintk(fmt, args);
102+
}
103+
104+
void bch2_print_opts(struct bch_opts *opts, const char *fmt, ...)
105+
{
106+
struct stdio_redirect *stdio = (void *)(unsigned long)opts->stdio;
107+
108+
va_list args;
109+
va_start(args, fmt);
110+
bch2_print_maybe_redirect(stdio, fmt, args);
104111
va_end(args);
105112
}
106113

@@ -110,14 +117,7 @@ void __bch2_print(struct bch_fs *c, const char *fmt, ...)
110117

111118
va_list args;
112119
va_start(args, fmt);
113-
if (likely(!stdio)) {
114-
vprintk(fmt, args);
115-
} else {
116-
if (fmt[0] == KERN_SOH[0])
117-
fmt += 2;
118-
119-
bch2_stdio_redirect_vprintf(stdio, true, fmt, args);
120-
}
120+
bch2_print_maybe_redirect(stdio, fmt, args);
121121
va_end(args);
122122
}
123123

0 commit comments

Comments
 (0)