diff options
author | Kent Overstreet <kent.overstreet@gmail.com> | 2018-07-23 09:13:07 -0400 |
---|---|---|
committer | Kent Overstreet <kent.overstreet@linux.dev> | 2023-10-22 17:08:08 -0400 |
commit | 277c981c634f3e64dd99523aabfd9ed5e6c5be55 (patch) | |
tree | 71639c412531bfe8e8e992508645bedf8fdcc8fa /fs/bcachefs/dirent.c | |
parent | bb1b3658aa7259bdacf7500abdeb8fdff61a51ba (diff) |
bcachefs: fix bch2_val_to_text()
was returning wrong value
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
Diffstat (limited to 'fs/bcachefs/dirent.c')
-rw-r--r-- | fs/bcachefs/dirent.c | 16 |
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, |