File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11// SPDX-License-Identifier: LGPL-2.1+
22/* Copyright (C) 2022 Kent Overstreet */
33
4+ #include <linux/bitmap.h>
45#include <linux/err.h>
56#include <linux/export.h>
67#include <linux/kernel.h>
@@ -423,3 +424,24 @@ void bch2_prt_bitflags(struct printbuf *out,
423424 flags ^= BIT_ULL (bit );
424425 }
425426}
427+
428+ void bch2_prt_bitflags_vector (struct printbuf * out ,
429+ const char * const list [],
430+ unsigned long * v , unsigned nr )
431+ {
432+ bool first = true;
433+ unsigned i ;
434+
435+ for (i = 0 ; i < nr ; i ++ )
436+ if (!list [i ]) {
437+ nr = i - 1 ;
438+ break ;
439+ }
440+
441+ for_each_set_bit (i , v , nr ) {
442+ if (!first )
443+ bch2_prt_printf (out , "," );
444+ first = false;
445+ bch2_prt_printf (out , "%s" , list [i ]);
446+ }
447+ }
Original file line number Diff line number Diff line change @@ -124,6 +124,8 @@ void bch2_prt_units_u64(struct printbuf *, u64);
124124void bch2_prt_units_s64 (struct printbuf * , s64 );
125125void bch2_prt_string_option (struct printbuf * , const char * const [], size_t );
126126void bch2_prt_bitflags (struct printbuf * , const char * const [], u64 );
127+ void bch2_prt_bitflags_vector (struct printbuf * , const char * const [],
128+ unsigned long * , unsigned );
127129
128130/* Initializer for a heap allocated printbuf: */
129131#define PRINTBUF ((struct printbuf) { .heap_allocated = true })
Original file line number Diff line number Diff line change @@ -243,6 +243,7 @@ do { \
243243#define prt_units_s64 (...) bch2_prt_units_s64(__VA_ARGS__)
244244#define prt_string_option (...) bch2_prt_string_option(__VA_ARGS__)
245245#define prt_bitflags (...) bch2_prt_bitflags(__VA_ARGS__)
246+ #define prt_bitflags_vector (...) bch2_prt_bitflags_vector(__VA_ARGS__)
246247
247248void bch2_pr_time_units (struct printbuf *, u64 );
248249void bch2_prt_datetime (struct printbuf *, time64_t );
You can’t perform that action at this time.
0 commit comments