diff options
author | Kent Overstreet <kent.overstreet@gmail.com> | 2022-08-14 14:44:17 -0400 |
---|---|---|
committer | Kent Overstreet <kent.overstreet@linux.dev> | 2023-10-22 17:09:38 -0400 |
commit | d0b50524f1d9b60318b92830546b45cd3325cfe2 (patch) | |
tree | 06b1e2c3ee3838177342d1139be73713e65a5cf9 /fs/bcachefs/util.c | |
parent | f0d2e9f2e511c137b75f15d0d13abd0217239253 (diff) |
bcachefs: bch2_bkey_packed_to_binary_text()
For debugging the eytzinger search tree code, and low level bkey packing
code, it can be helpful to see things in binary: this patch improves our
helpers for doing so.
Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
Diffstat (limited to 'fs/bcachefs/util.c')
-rw-r--r-- | fs/bcachefs/util.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/fs/bcachefs/util.c b/fs/bcachefs/util.c index cb07ef2ceb59..61cd44c5a6b4 100644 --- a/fs/bcachefs/util.c +++ b/fs/bcachefs/util.c @@ -238,6 +238,12 @@ bool bch2_is_zero(const void *_p, size_t n) return true; } +void bch2_prt_u64_binary(struct printbuf *out, u64 v, unsigned nr_bits) +{ + while (nr_bits) + prt_char(out, '0' + ((v >> --nr_bits) & 1)); +} + /* time stats: */ #ifndef CONFIG_BCACHEFS_NO_LATENCY_ACCT |