diff options
author | Kent Overstreet <kent.overstreet@gmail.com> | 2022-06-09 01:13:46 -0400 |
---|---|---|
committer | Kent Overstreet <kent.overstreet@gmail.com> | 2022-06-09 15:07:25 -0400 |
commit | 6ac37db8415c636607d878c16af8346df55668f4 (patch) | |
tree | 9c41e2d77899017d8deebc20d3d125541d476457 /linux/printbuf_userspace.c | |
parent | bec3a265658010a6cbf0cfac6dca461a7edf2c7d (diff) |
Update bcachefs sources to 24f7e08cd8 bcachefs: shrinker.to_text() methods
Diffstat (limited to 'linux/printbuf_userspace.c')
-rw-r--r-- | linux/printbuf_userspace.c | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/linux/printbuf_userspace.c b/linux/printbuf_userspace.c new file mode 100644 index 00000000..84187f1f --- /dev/null +++ b/linux/printbuf_userspace.c @@ -0,0 +1,20 @@ + +#include <stdio.h> +#include <linux/printbuf.h> + +void prt_printf(struct printbuf *out, const char *fmt, ...) +{ + va_list args; + int len; + + do { + va_start(args, fmt); + len = vsnprintf(out->buf + out->pos, printbuf_remaining(out), fmt, args); + va_end(args); + } while (len + 1 >= printbuf_remaining(out) && + !printbuf_make_room(out, len + 1)); + + len = min_t(size_t, len, + printbuf_remaining(out) ? printbuf_remaining(out) - 1 : 0); + out->pos += len; +} |