]> git.sesse.net Git - bcachefs-tools-debian/blobdiff - libbcachefs/printbuf.c
Update bcachefs sources to 2a6125decb43 bcachefs: bch_sb_field_downgrade
[bcachefs-tools-debian] / libbcachefs / printbuf.c
index 5e653eb81d54f8fdfcca37038eeaf5a1febdb8e7..187b0377bd40522ebb35235c64723f13bfaa5742 100644 (file)
@@ -2,6 +2,7 @@
 /* Copyright (C) 2022 Kent Overstreet */
 
 #include <linux/err.h>
+#include <linux/bitmap.h>
 #include <linux/export.h>
 #include <linux/kernel.h>
 #include <linux/slab.h>
@@ -423,3 +424,24 @@ void bch2_prt_bitflags(struct printbuf *out,
                flags ^= BIT_ULL(bit);
        }
 }
+
+void bch2_prt_bitflags_vector(struct printbuf *out,
+                             const char * const list[],
+                             unsigned long *v, unsigned nr)
+{
+       bool first = true;
+       unsigned i;
+
+       for (i = 0; i < nr; i++)
+               if (!list[i]) {
+                       nr = i - 1;
+                       break;
+               }
+
+       for_each_set_bit(i, v, nr) {
+               if (!first)
+                       bch2_prt_printf(out, ",");
+               first = false;
+               bch2_prt_printf(out, "%s", list[i]);
+       }
+}