ovl: clean up ovl_getxattr() in copy_up.c
Lose the padding and the failure message (in line with other parts of the copy up process). Return zero for both nonexistent or empty xattr. Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
This commit is contained in:
parent
fee0f2980a
commit
de7a52c9c6
1 changed files with 11 additions and 21 deletions
|
@ -784,36 +784,26 @@ static bool ovl_need_meta_copy_up(struct dentry *dentry, umode_t mode,
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static ssize_t ovl_getxattr(struct dentry *dentry, char *name, char **value,
|
static ssize_t ovl_getxattr(struct dentry *dentry, char *name, char **value)
|
||||||
size_t padding)
|
|
||||||
{
|
{
|
||||||
ssize_t res;
|
ssize_t res;
|
||||||
char *buf = NULL;
|
char *buf;
|
||||||
|
|
||||||
res = vfs_getxattr(dentry, name, NULL, 0);
|
res = vfs_getxattr(dentry, name, NULL, 0);
|
||||||
if (res < 0) {
|
if (res == -ENODATA || res == -EOPNOTSUPP)
|
||||||
if (res == -ENODATA || res == -EOPNOTSUPP)
|
res = 0;
|
||||||
return -ENODATA;
|
|
||||||
goto fail;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (res != 0) {
|
if (res > 0) {
|
||||||
buf = kzalloc(res + padding, GFP_KERNEL);
|
buf = kzalloc(res, GFP_KERNEL);
|
||||||
if (!buf)
|
if (!buf)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
res = vfs_getxattr(dentry, name, buf, res);
|
res = vfs_getxattr(dentry, name, buf, res);
|
||||||
if (res < 0)
|
if (res < 0)
|
||||||
goto fail;
|
kfree(buf);
|
||||||
|
else
|
||||||
|
*value = buf;
|
||||||
}
|
}
|
||||||
*value = buf;
|
|
||||||
|
|
||||||
return res;
|
|
||||||
|
|
||||||
fail:
|
|
||||||
pr_warn_ratelimited("failed to get xattr %s: err=%zi)\n",
|
|
||||||
name, res);
|
|
||||||
kfree(buf);
|
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -836,8 +826,8 @@ static int ovl_copy_up_meta_inode_data(struct ovl_copy_up_ctx *c)
|
||||||
|
|
||||||
if (c->stat.size) {
|
if (c->stat.size) {
|
||||||
err = cap_size = ovl_getxattr(upperpath.dentry, XATTR_NAME_CAPS,
|
err = cap_size = ovl_getxattr(upperpath.dentry, XATTR_NAME_CAPS,
|
||||||
&capability, 0);
|
&capability);
|
||||||
if (err < 0 && err != -ENODATA)
|
if (cap_size < 0)
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue