summaryrefslogtreecommitdiff
path: root/fs/bcachefs/xattr.c
diff options
context:
space:
mode:
authorKent Overstreet <kent.overstreet@gmail.com>2018-07-23 16:13:07 +0300
committerKent Overstreet <kent.overstreet@linux.dev>2023-10-23 00:08:08 +0300
commit277c981c634f3e64dd99523aabfd9ed5e6c5be55 (patch)
tree71639c412531bfe8e8e992508645bedf8fdcc8fa /fs/bcachefs/xattr.c
parentbb1b3658aa7259bdacf7500abdeb8fdff61a51ba (diff)
downloadlinux-277c981c634f3e64dd99523aabfd9ed5e6c5be55.tar.xz
bcachefs: fix bch2_val_to_text()
was returning wrong value Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
Diffstat (limited to 'fs/bcachefs/xattr.c')
-rw-r--r--fs/bcachefs/xattr.c32
1 files changed, 17 insertions, 15 deletions
diff --git a/fs/bcachefs/xattr.c b/fs/bcachefs/xattr.c
index cb84bdabb6ed..44bf4a2f3c84 100644
--- a/fs/bcachefs/xattr.c
+++ b/fs/bcachefs/xattr.c
@@ -111,12 +111,12 @@ const char *bch2_xattr_invalid(const struct bch_fs *c, struct bkey_s_c k)
}
}
-void bch2_xattr_to_text(struct bch_fs *c, char *buf,
- size_t size, struct bkey_s_c k)
+int bch2_xattr_to_text(struct bch_fs *c, char *buf,
+ size_t size, struct bkey_s_c k)
{
+ char *out = buf, *end = buf + size;
const struct xattr_handler *handler;
struct bkey_s_c_xattr xattr;
- size_t n = 0;
switch (k.k->type) {
case BCH_XATTR:
@@ -124,24 +124,26 @@ void bch2_xattr_to_text(struct bch_fs *c, char *buf,
handler = bch2_xattr_type_to_handler(xattr.v->x_type);
if (handler && handler->prefix)
- n += scnprintf(buf + n, size - n, "%s", handler->prefix);
+ out += scnprintf(out, end - out, "%s", handler->prefix);
else if (handler)
- n += scnprintf(buf + n, size - n, "(type %u)",
- xattr.v->x_type);
+ out += scnprintf(out, end - out, "(type %u)",
+ xattr.v->x_type);
else
- n += scnprintf(buf + n, size - n, "(unknown type %u)",
- xattr.v->x_type);
-
- n += bch_scnmemcpy(buf + n, size - n, xattr.v->x_name,
- xattr.v->x_name_len);
- n += scnprintf(buf + n, size - n, ":");
- n += bch_scnmemcpy(buf + n, size - n, xattr_val(xattr.v),
- le16_to_cpu(xattr.v->x_val_len));
+ out += scnprintf(out, end - out, "(unknown type %u)",
+ xattr.v->x_type);
+
+ out += bch_scnmemcpy(out, end - out, xattr.v->x_name,
+ xattr.v->x_name_len);
+ out += scnprintf(out, end - out, ":");
+ out += bch_scnmemcpy(out, end - out, xattr_val(xattr.v),
+ le16_to_cpu(xattr.v->x_val_len));
break;
case BCH_XATTR_WHITEOUT:
- scnprintf(buf, size, "whiteout");
+ out += scnprintf(out, end - out, "whiteout");
break;
}
+
+ return out - buf;
}
int bch2_xattr_get(struct bch_fs *c, struct bch_inode_info *inode,