mirror of https://github.com/xqemu/xqemu.git
virtio-9p: Add support for removing xattr
Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
This commit is contained in:
parent
783f04e1d4
commit
9ed3ef26e6
|
@ -91,6 +91,7 @@ typedef struct FileOperations
|
||||||
ssize_t (*llistxattr)(FsContext *, const char *, void *, size_t);
|
ssize_t (*llistxattr)(FsContext *, const char *, void *, size_t);
|
||||||
int (*lsetxattr)(FsContext *, const char *,
|
int (*lsetxattr)(FsContext *, const char *,
|
||||||
const char *, void *, size_t, int);
|
const char *, void *, size_t, int);
|
||||||
|
int (*lremovexattr)(FsContext *, const char *, const char *);
|
||||||
void *opaque;
|
void *opaque;
|
||||||
} FileOperations;
|
} FileOperations;
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -581,6 +581,22 @@ static int local_lsetxattr(FsContext *ctx, const char *path, const char *name,
|
||||||
return lsetxattr(rpath(ctx, path), name, value, size, flags);
|
return lsetxattr(rpath(ctx, path), name, value, size, flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int local_lremovexattr(FsContext *ctx,
|
||||||
|
const char *path, const char *name)
|
||||||
|
{
|
||||||
|
if ((ctx->fs_sm == SM_MAPPED) &&
|
||||||
|
(strncmp(name, "user.virtfs.", 12) == 0)) {
|
||||||
|
/*
|
||||||
|
* Don't allow fetch of user.virtfs namesapce
|
||||||
|
* in case of mapped security
|
||||||
|
*/
|
||||||
|
errno = EACCES;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
return lremovexattr(rpath(ctx, path), name);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
FileOperations local_ops = {
|
FileOperations local_ops = {
|
||||||
.lstat = local_lstat,
|
.lstat = local_lstat,
|
||||||
.readlink = local_readlink,
|
.readlink = local_readlink,
|
||||||
|
@ -612,4 +628,5 @@ FileOperations local_ops = {
|
||||||
.lgetxattr = local_lgetxattr,
|
.lgetxattr = local_lgetxattr,
|
||||||
.llistxattr = local_llistxattr,
|
.llistxattr = local_llistxattr,
|
||||||
.lsetxattr = local_lsetxattr,
|
.lsetxattr = local_lsetxattr,
|
||||||
|
.lremovexattr = local_lremovexattr,
|
||||||
};
|
};
|
||||||
|
|
|
@ -286,6 +286,14 @@ static int v9fs_do_lsetxattr(V9fsState *s, V9fsString *path,
|
||||||
xattr_name->data, value, size, flags);
|
xattr_name->data, value, size, flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int v9fs_do_lremovexattr(V9fsState *s, V9fsString *path,
|
||||||
|
V9fsString *xattr_name)
|
||||||
|
{
|
||||||
|
return s->ops->lremovexattr(&s->ctx, path->data,
|
||||||
|
xattr_name->data);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static void v9fs_string_init(V9fsString *str)
|
static void v9fs_string_init(V9fsString *str)
|
||||||
{
|
{
|
||||||
str->data = NULL;
|
str->data = NULL;
|
||||||
|
@ -456,10 +464,14 @@ static int v9fs_xattr_fid_clunk(V9fsState *s, V9fsFidState *fidp)
|
||||||
retval = -EINVAL;
|
retval = -EINVAL;
|
||||||
goto free_out;
|
goto free_out;
|
||||||
}
|
}
|
||||||
retval = v9fs_do_lsetxattr(s, &fidp->path, &fidp->fs.xattr.name,
|
if (fidp->fs.xattr.len) {
|
||||||
fidp->fs.xattr.value,
|
retval = v9fs_do_lsetxattr(s, &fidp->path, &fidp->fs.xattr.name,
|
||||||
fidp->fs.xattr.len,
|
fidp->fs.xattr.value,
|
||||||
fidp->fs.xattr.flags);
|
fidp->fs.xattr.len,
|
||||||
|
fidp->fs.xattr.flags);
|
||||||
|
} else {
|
||||||
|
retval = v9fs_do_lremovexattr(s, &fidp->path, &fidp->fs.xattr.name);
|
||||||
|
}
|
||||||
free_out:
|
free_out:
|
||||||
v9fs_string_free(&fidp->fs.xattr.name);
|
v9fs_string_free(&fidp->fs.xattr.name);
|
||||||
free_value:
|
free_value:
|
||||||
|
@ -3392,7 +3404,10 @@ static void v9fs_xattrcreate(V9fsState *s, V9fsPDU *pdu)
|
||||||
vs->xattr_fidp->fs.xattr.flags = flags;
|
vs->xattr_fidp->fs.xattr.flags = flags;
|
||||||
v9fs_string_init(&vs->xattr_fidp->fs.xattr.name);
|
v9fs_string_init(&vs->xattr_fidp->fs.xattr.name);
|
||||||
v9fs_string_copy(&vs->xattr_fidp->fs.xattr.name, &vs->name);
|
v9fs_string_copy(&vs->xattr_fidp->fs.xattr.name, &vs->name);
|
||||||
vs->xattr_fidp->fs.xattr.value = qemu_malloc(vs->size);
|
if (vs->size)
|
||||||
|
vs->xattr_fidp->fs.xattr.value = qemu_malloc(vs->size);
|
||||||
|
else
|
||||||
|
vs->xattr_fidp->fs.xattr.value = NULL;
|
||||||
|
|
||||||
out:
|
out:
|
||||||
complete_pdu(s, vs->pdu, err);
|
complete_pdu(s, vs->pdu, err);
|
||||||
|
|
Loading…
Reference in New Issue