summaryrefslogtreecommitdiff
path: root/libbcachefs/xattr.c
diff options
context:
space:
mode:
Diffstat (limited to 'libbcachefs/xattr.c')
-rw-r--r--libbcachefs/xattr.c34
1 files changed, 18 insertions, 16 deletions
diff --git a/libbcachefs/xattr.c b/libbcachefs/xattr.c
index 7d0fee3a..398bc534 100644
--- a/libbcachefs/xattr.c
+++ b/libbcachefs/xattr.c
@@ -110,12 +110,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:
@@ -123,24 +123,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,
@@ -433,7 +435,7 @@ static int bch2_xattr_bcachefs_set(const struct xattr_handler *handler,
}
mutex_lock(&inode->ei_update_lock);
- ret = __bch2_write_inode(c, inode, inode_opt_set_fn, &s, 0);
+ ret = bch2_write_inode(c, inode, inode_opt_set_fn, &s, 0);
mutex_unlock(&inode->ei_update_lock);
if (value &&