[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH -V3 12/32] virtio-9p: Implement P9_TREMOVE
From: |
Aneesh Kumar K.V |
Subject: |
[Qemu-devel] [PATCH -V3 12/32] virtio-9p: Implement P9_TREMOVE |
Date: |
Thu, 25 Mar 2010 22:13:20 +0530 |
From: Anthony Liguori <address@hidden>
This gets file deletion to work
address@hidden: Fix truncate to use the relative path]
Signed-off-by: Anthony Liguori <address@hidden>
Signed-off-by: Gautham R Shenoy <address@hidden>
Signed-off-by: Aneesh Kumar K.V <address@hidden>
---
hw/virtio-9p-local.c | 7 ++++++
hw/virtio-9p.c | 54 ++++++++++++++++++++++++++++++++++++++++++++++++-
2 files changed, 59 insertions(+), 2 deletions(-)
diff --git a/hw/virtio-9p-local.c b/hw/virtio-9p-local.c
index 829e79a..dca6175 100644
--- a/hw/virtio-9p-local.c
+++ b/hw/virtio-9p-local.c
@@ -245,6 +245,12 @@ static int local_utime(void *opaque, const char *path,
return utime(rpath(path), buf);
}
+static int local_remove(void *opaque, const char *path)
+{
+ return remove(rpath(path));
+}
+
+
static V9fsPosixFileOperations ops = {
.lstat = local_lstat,
.setuid = local_setuid,
@@ -272,6 +278,7 @@ static V9fsPosixFileOperations ops = {
.rename = local_rename,
.chown = local_chown,
.utime = local_utime,
+ .remove = local_remove,
};
V9fsPosixFileOperations *virtio_9p_init_local(const char *path)
diff --git a/hw/virtio-9p.c b/hw/virtio-9p.c
index c8995a3..4478e57 100644
--- a/hw/virtio-9p.c
+++ b/hw/virtio-9p.c
@@ -237,6 +237,11 @@ static int posix_utime(V9fsState *s, V9fsString *path,
return s->ops->utime(s->ops->opaque, path->data, buf);
}
+static int posix_remove(V9fsState *s, V9fsString *path)
+{
+ return s->ops->remove(s->ops->opaque, path->data);
+}
+
static void v9fs_string_init(V9fsString *str)
{
str->data = NULL;
@@ -1716,10 +1721,55 @@ static void v9fs_flush(V9fsState *s, V9fsPDU *pdu)
pprint_pdu(pdu);
}
+typedef struct V9fsRemoveState {
+ V9fsPDU *pdu;
+ size_t offset;
+ int32_t fid;
+ V9fsFidState *fidp;
+} V9fsRemoveState;
+
+static void v9fs_remove_post_remove(V9fsState *s, V9fsRemoveState *vs,
+ int err)
+{
+ if (err) {
+ err = -errno;
+ goto out;
+ }
+
+ err = free_fid(s, vs->fid);
+ if (err < 0)
+ goto out;
+
+ err = vs->offset;
+out:
+ complete_pdu(s, vs->pdu, err);
+ qemu_free(vs);
+}
+
static void v9fs_remove(V9fsState *s, V9fsPDU *pdu)
{
- if (debug_9p_pdu)
- pprint_pdu(pdu);
+ V9fsRemoveState *vs;
+ int err = 0;
+
+ vs = qemu_malloc(sizeof(*vs));
+ vs->pdu = pdu;
+ vs->offset = 7;
+
+ pdu_unmarshal(vs->pdu, vs->offset, "d", &vs->fid);
+
+ vs->fidp = lookup_fid(s, vs->fid);
+ if (vs->fidp == NULL) {
+ err = -EINVAL;
+ goto out;
+ }
+
+ err = posix_remove(s, &vs->fidp->path);
+ v9fs_remove_post_remove(s, vs, err);
+ return;
+
+out:
+ complete_pdu(s, pdu, err);
+ qemu_free(vs);
}
static mode_t v9mode_to_mode(uint32_t mode, V9fsString *extension)
--
1.7.0.2.323.g0d092
[Qemu-devel] [PATCH -V3 08/32] virtio-9p: Implement P9_TCLUNK, Aneesh Kumar K.V, 2010/03/25
[Qemu-devel] [PATCH -V3 04/32] virtio-9p: Implement P9_TSTAT, Aneesh Kumar K.V, 2010/03/25
[Qemu-devel] [PATCH -V3 10/32] virtio-9p: Implement P9_TCREATE, Aneesh Kumar K.V, 2010/03/25
[Qemu-devel] [PATCH -V3 11/32] virtio-9p: Implement P9_TWSTAT, Aneesh Kumar K.V, 2010/03/25
[Qemu-devel] [PATCH -V3 12/32] virtio-9p: Implement P9_TREMOVE,
Aneesh Kumar K.V <=
[Qemu-devel] [PATCH -V3 14/32] virtio-9p: Add multiple mount point support, Aneesh Kumar K.V, 2010/03/25
[Qemu-devel] [PATCH -V3 16/32] virtio-9p: Add support for hardlink, Aneesh Kumar K.V, 2010/03/25
[Qemu-devel] [PATCH -V3 13/32] virtio-9p: Implement P9_TFLUSH, Aneesh Kumar K.V, 2010/03/25
[Qemu-devel] [PATCH -V3 17/32] Implement sync support in 9p server, Aneesh Kumar K.V, 2010/03/25
[Qemu-devel] [PATCH -V3 15/32] virtio-9p: Use little endian format on virtio, Aneesh Kumar K.V, 2010/03/25
[Qemu-devel] [PATCH -V3 18/32] virtio-9p: Fix sg usage in the code, Aneesh Kumar K.V, 2010/03/25
[Qemu-devel] [PATCH -V3 19/32] virtio-9p: Get the correct count values from the pdu, Aneesh Kumar K.V, 2010/03/25
[Qemu-devel] [PATCH -V3 22/32] virtio-9p: Update existing fid path on rename, Aneesh Kumar K.V, 2010/03/25
[Qemu-devel] [PATCH -V3 21/32] virtio-9p: Remove unnecessary definition of fid, Aneesh Kumar K.V, 2010/03/25
[Qemu-devel] [PATCH -V3 23/32] vritio-9p: Fix chmod bug with directory, Aneesh Kumar K.V, 2010/03/25