+static inline void pr_char(struct printbuf *out, char c)
+{
+ bch2_pr_buf(out, "%c", c);
+}
+
+static inline void pr_indent_push(struct printbuf *buf, unsigned spaces)
+{
+ buf->indent += spaces;
+ while (spaces--)
+ pr_char(buf, ' ');
+}
+
+static inline void pr_indent_pop(struct printbuf *buf, unsigned spaces)
+{
+ if (buf->last_newline + buf->indent == buf->pos) {
+ buf->pos -= spaces;
+ buf->buf[buf->pos] = 0;
+ }
+ buf->indent -= spaces;
+}
+
+static inline void pr_newline(struct printbuf *buf)
+{
+ unsigned i;
+
+ pr_char(buf, '\n');
+
+ buf->last_newline = buf->pos;
+
+ for (i = 0; i < buf->indent; i++)
+ pr_char(buf, ' ');
+
+ buf->last_field = buf->pos;
+ buf->tabstop = 0;
+}
+
+static inline void pr_tab(struct printbuf *buf)
+{
+ BUG_ON(buf->tabstop > ARRAY_SIZE(buf->tabstops));
+
+ while (printbuf_remaining(buf) > 1 &&
+ printbuf_linelen(buf) < buf->tabstops[buf->tabstop])
+ pr_char(buf, ' ');
+
+ buf->last_field = buf->pos;
+ buf->tabstop++;
+}
+
+void bch2_pr_tab_rjust(struct printbuf *);
+
+static inline void pr_tab_rjust(struct printbuf *buf)
+{
+ bch2_pr_tab_rjust(buf);
+}
+
+void bch2_pr_units(struct printbuf *, s64, s64);
+#define pr_units(...) bch2_pr_units(__VA_ARGS__)
+
+static inline void pr_sectors(struct printbuf *out, u64 v)
+{
+ bch2_pr_units(out, v, v << 9);
+}
+
+#ifdef __KERNEL__
+static inline void pr_time(struct printbuf *out, u64 time)
+{
+ pr_buf(out, "%llu", time);
+}
+#else
+#include <time.h>
+static inline void pr_time(struct printbuf *out, u64 _time)
+{
+ char time_str[64];
+ time_t time = _time;
+ struct tm *tm = localtime(&time);
+ size_t err = strftime(time_str, sizeof(time_str), "%c", tm);
+ if (!err)
+ pr_buf(out, "(formatting error)");
+ else
+ pr_buf(out, "%s", time_str);
+}
+#endif
+
+#ifdef __KERNEL__
+static inline void uuid_unparse_lower(u8 *uuid, char *out)
+{
+ sprintf(out, "%pUb", uuid);
+}
+#else
+#include <uuid/uuid.h>
+#endif
+
+static inline void pr_uuid(struct printbuf *out, u8 *uuid)
+{
+ char uuid_str[40];
+
+ uuid_unparse_lower(uuid, uuid_str);
+ pr_buf(out, "%s", uuid_str);
+}