summaryrefslogtreecommitdiff
path: root/fs/bcachefs/util.h
diff options
context:
space:
mode:
authorKent Overstreet <kent.overstreet@gmail.com>2022-02-16 10:50:39 +0300
committerKent Overstreet <kent.overstreet@linux.dev>2023-10-23 00:09:24 +0300
commite7bc7cdff813719479d555d9a3ebb62bef3050ce (patch)
treeaccd056183f5fb35231659d3f80d89149aa4c3d4 /fs/bcachefs/util.h
parent33aa419db96077993af90eddb49adac1270a96e0 (diff)
downloadlinux-e7bc7cdff813719479d555d9a3ebb62bef3050ce.tar.xz
bcachefs: Improve journal_entry_btree_keys_to_text()
This improves the formatting of journal_entry_btree_keys_to_text() by putting each key on its own line. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
Diffstat (limited to 'fs/bcachefs/util.h')
-rw-r--r--fs/bcachefs/util.h22
1 files changed, 22 insertions, 0 deletions
diff --git a/fs/bcachefs/util.h b/fs/bcachefs/util.h
index fbe5b710e9c5..e047e7860584 100644
--- a/fs/bcachefs/util.h
+++ b/fs/bcachefs/util.h
@@ -238,6 +238,7 @@ do { \
struct printbuf {
char *pos;
char *end;
+ unsigned indent;
};
static inline size_t printbuf_remaining(struct printbuf *buf)
@@ -259,6 +260,27 @@ do { \
__VA_ARGS__); \
} while (0)
+static inline void printbuf_indent_push(struct printbuf *buf, unsigned spaces)
+{
+ buf->indent += spaces;
+ while (spaces--)
+ pr_buf(buf, " ");
+}
+
+static inline void printbuf_indent_pop(struct printbuf *buf, unsigned spaces)
+{
+ buf->indent -= spaces;
+}
+
+static inline void printbuf_newline(struct printbuf *buf)
+{
+ unsigned i;
+
+ pr_buf(buf, "\n");
+ for (i = 0; i < buf->indent; i++)
+ pr_buf(buf, " ");
+}
+
void bch_scnmemcpy(struct printbuf *, const char *, size_t);
int bch2_strtoint_h(const char *, int *);