summaryrefslogtreecommitdiff
path: root/fs/bcachefs/dirent.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/bcachefs/dirent.c')
-rw-r--r--fs/bcachefs/dirent.c16
1 files changed, 9 insertions, 7 deletions
diff --git a/fs/bcachefs/dirent.c b/fs/bcachefs/dirent.c
index 18078cc2ca62..d5e174e1e59f 100644
--- a/fs/bcachefs/dirent.c
+++ b/fs/bcachefs/dirent.c
@@ -122,24 +122,26 @@ const char *bch2_dirent_invalid(const struct bch_fs *c, struct bkey_s_c k)
}
}
-void bch2_dirent_to_text(struct bch_fs *c, char *buf,
- size_t size, struct bkey_s_c k)
+int bch2_dirent_to_text(struct bch_fs *c, char *buf,
+ size_t size, struct bkey_s_c k)
{
+ char *out = buf, *end = buf + size;
struct bkey_s_c_dirent d;
- size_t n = 0;
switch (k.k->type) {
case BCH_DIRENT:
d = bkey_s_c_to_dirent(k);
- n += bch_scnmemcpy(buf + n, size - n, d.v->d_name,
- bch2_dirent_name_bytes(d));
- n += scnprintf(buf + n, size - n, " -> %llu", d.v->d_inum);
+ out += bch_scnmemcpy(out, end - out, d.v->d_name,
+ bch2_dirent_name_bytes(d));
+ out += scnprintf(out, end - out, " -> %llu", d.v->d_inum);
break;
case BCH_DIRENT_WHITEOUT:
- scnprintf(buf, size, "whiteout");
+ out += scnprintf(out, end - out, "whiteout");
break;
}
+
+ return out - buf;
}
static struct bkey_i_dirent *dirent_create_key(struct btree_trans *trans,