[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH -V5 24/28] virtio-9p: Add support for removing xattr
From: |
Venkateswararao Jujjuri (JV) |
Subject: |
[Qemu-devel] [PATCH -V5 24/28] virtio-9p: Add support for removing xattr |
Date: |
Thu, 2 Sep 2010 12:39:44 -0700 |
From: Aneesh Kumar K.V <address@hidden>
Signed-off-by: Aneesh Kumar K.V <address@hidden>
Signed-off-by: Venkateswararao Jujjuri <address@hidden>
---
hw/file-op-9p.h | 1 +
hw/virtio-9p-local.c | 17 +++++++++++++++++
hw/virtio-9p.c | 25 ++++++++++++++++++++-----
3 files changed, 38 insertions(+), 5 deletions(-)
diff --git a/hw/file-op-9p.h b/hw/file-op-9p.h
index 017183d..d91b7e7 100644
--- a/hw/file-op-9p.h
+++ b/hw/file-op-9p.h
@@ -91,6 +91,7 @@ typedef struct FileOperations
ssize_t (*llistxattr)(FsContext *, const char *, void *, size_t);
int (*lsetxattr)(FsContext *, const char *,
const char *, void *, size_t, int);
+ int (*lremovexattr)(FsContext *, const char *, const char *);
void *opaque;
} FileOperations;
#endif
diff --git a/hw/virtio-9p-local.c b/hw/virtio-9p-local.c
index 132816e..57f9243 100644
--- a/hw/virtio-9p-local.c
+++ b/hw/virtio-9p-local.c
@@ -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);
}
+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 = {
.lstat = local_lstat,
.readlink = local_readlink,
@@ -612,4 +628,5 @@ FileOperations local_ops = {
.lgetxattr = local_lgetxattr,
.llistxattr = local_llistxattr,
.lsetxattr = local_lsetxattr,
+ .lremovexattr = local_lremovexattr,
};
diff --git a/hw/virtio-9p.c b/hw/virtio-9p.c
index a53b222..eb7ae01 100644
--- a/hw/virtio-9p.c
+++ b/hw/virtio-9p.c
@@ -286,6 +286,14 @@ static int v9fs_do_lsetxattr(V9fsState *s, V9fsString
*path,
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)
{
str->data = NULL;
@@ -456,10 +464,14 @@ static int v9fs_xattr_fid_clunk(V9fsState *s,
V9fsFidState *fidp)
retval = -EINVAL;
goto free_out;
}
- retval = v9fs_do_lsetxattr(s, &fidp->path, &fidp->fs.xattr.name,
- fidp->fs.xattr.value,
- fidp->fs.xattr.len,
- fidp->fs.xattr.flags);
+ if (fidp->fs.xattr.len) {
+ retval = v9fs_do_lsetxattr(s, &fidp->path, &fidp->fs.xattr.name,
+ fidp->fs.xattr.value,
+ fidp->fs.xattr.len,
+ fidp->fs.xattr.flags);
+ } else {
+ retval = v9fs_do_lremovexattr(s, &fidp->path, &fidp->fs.xattr.name);
+ }
free_out:
v9fs_string_free(&fidp->fs.xattr.name);
free_value:
@@ -3392,7 +3404,10 @@ static void v9fs_xattrcreate(V9fsState *s, V9fsPDU *pdu)
vs->xattr_fidp->fs.xattr.flags = flags;
v9fs_string_init(&vs->xattr_fidp->fs.xattr.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:
complete_pdu(s, vs->pdu, err);
--
1.6.5.2
- [Qemu-devel] [PATCH -V5 15/28] rename - change name of file or directory, (continued)
- [Qemu-devel] [PATCH -V5 15/28] rename - change name of file or directory, Venkateswararao Jujjuri (JV), 2010/09/02
- [Qemu-devel] [PATCH -V5 16/28] [virtio-9p] qemu: virtio-9p: Implement LOPEN, Venkateswararao Jujjuri (JV), 2010/09/02
- [Qemu-devel] [PATCH -V5 13/28] qemu: virtio-9p: Implement TMKNOD, Venkateswararao Jujjuri (JV), 2010/09/02
- [Qemu-devel] [PATCH -V5 17/28] virtio-9p: Add fidtype so that we can do type specific operation, Venkateswararao Jujjuri (JV), 2010/09/02
- [Qemu-devel] [PATCH -V5 14/28] qemu: virtio-9p: Implement TMKDIR, Venkateswararao Jujjuri (JV), 2010/09/02
- [Qemu-devel] [PATCH -V5 18/28] virtio-9p: Implement TXATTRWALK, Venkateswararao Jujjuri (JV), 2010/09/02
- [Qemu-devel] [PATCH -V5 20/28] virtio-9p: Hide user.virtfs xattr in case of mapped security., Venkateswararao Jujjuri (JV), 2010/09/02
- [Qemu-devel] [PATCH -V5 22/28] virtio-9p: Use lchown which won't follow symlink, Venkateswararao Jujjuri (JV), 2010/09/02
- [Qemu-devel] [PATCH -V5 19/28] virtio-9p: Implement TXATTRCREATE, Venkateswararao Jujjuri (JV), 2010/09/02
- [Qemu-devel] [PATCH -V5 23/28] virtio-9p: Fix the memset usage, Venkateswararao Jujjuri (JV), 2010/09/02
- [Qemu-devel] [PATCH -V5 24/28] virtio-9p: Add support for removing xattr,
Venkateswararao Jujjuri (JV) <=
- [Qemu-devel] [PATCH -V5 25/28] virtio-9p: Make sure -virtfs option works correctly, Venkateswararao Jujjuri (JV), 2010/09/02
- [Qemu-devel] [PATCH -V5 26/28] [virtio-9p] Remove all instances of unnecessary dotu variable., Venkateswararao Jujjuri (JV), 2010/09/02
- [Qemu-devel] [PATCH -V5 21/28] virtio-9p: Add SM_NONE security model, Venkateswararao Jujjuri (JV), 2010/09/02
- [Qemu-devel] [PATCH -V5 27/28] [virtio-9p] This patch implements TLERROR/RLERROR on the qemu 9P server., Venkateswararao Jujjuri (JV), 2010/09/02
- [Qemu-devel] [PATCH -V5 28/28] virtio-9p: Change handling of flags in open() path for 9P2000.L, Venkateswararao Jujjuri (JV), 2010/09/02