bcachefs: Factor out jset_entry_log_msg_bytes()
Needed for improved userspace cmd_list_journal Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
This commit is contained in:
@@ -1219,6 +1219,15 @@ struct jset_entry_log {
|
||||
u8 d[];
|
||||
} __packed __aligned(8);
|
||||
|
||||
static inline unsigned jset_entry_log_msg_bytes(struct jset_entry_log *l)
|
||||
{
|
||||
unsigned b = vstruct_bytes(&l->entry) - offsetof(struct jset_entry_log, d);
|
||||
|
||||
while (b && !l->d[b - 1])
|
||||
--b;
|
||||
return b;
|
||||
}
|
||||
|
||||
struct jset_entry_datetime {
|
||||
struct jset_entry entry;
|
||||
__le64 seconds;
|
||||
|
||||
@@ -738,9 +738,8 @@ static void journal_entry_log_to_text(struct printbuf *out, struct bch_fs *c,
|
||||
struct jset_entry *entry)
|
||||
{
|
||||
struct jset_entry_log *l = container_of(entry, struct jset_entry_log, entry);
|
||||
unsigned bytes = vstruct_bytes(entry) - offsetof(struct jset_entry_log, d);
|
||||
|
||||
prt_printf(out, "%.*s", bytes, l->d);
|
||||
prt_printf(out, "%.*s", jset_entry_log_msg_bytes(l), l->d);
|
||||
}
|
||||
|
||||
static int journal_entry_overwrite_validate(struct bch_fs *c,
|
||||
|
||||
Reference in New Issue
Block a user