qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PATCH 08/25] [virtio-9p] clean up v9fs_mkdir.


From: Venkateswararao Jujjuri (JV)
Subject: [Qemu-devel] [PATCH 08/25] [virtio-9p] clean up v9fs_mkdir.
Date: Thu, 12 May 2011 13:57:30 -0700

Rearrange the code so that we can avoid V9fsMkState and additional malloc()s.

Signed-off-by: Venkateswararao Jujjuri "<address@hidden>
---
 hw/9pfs/virtio-9p.c |   39 +++++++++++++++++----------------------
 1 files changed, 17 insertions(+), 22 deletions(-)

diff --git a/hw/9pfs/virtio-9p.c b/hw/9pfs/virtio-9p.c
index af0143d..883eced 100644
--- a/hw/9pfs/virtio-9p.c
+++ b/hw/9pfs/virtio-9p.c
@@ -3360,47 +3360,42 @@ out:
 static void v9fs_mkdir(void *opaque)
 {
     V9fsCoPdu *copdu = opaque;
-    V9fsState *s = copdu->s;
-    V9fsPDU *pdu = copdu->pdu;
+    size_t offset = 7;
     int32_t fid;
-    V9fsMkState *vs;
-    int err = 0;
+    struct stat stbuf;
+    V9fsString name, fullname;
+    V9fsQID qid;
     V9fsFidState *fidp;
     gid_t gid;
     int mode;
+    int err = 0;
 
-    vs = qemu_malloc(sizeof(*vs));
-    vs->pdu = pdu;
-    vs->offset = 7;
-
-    v9fs_string_init(&vs->fullname);
-    pdu_unmarshal(vs->pdu, vs->offset, "dsdd", &fid, &vs->name, &mode,
-                  &gid);
+    v9fs_string_init(&fullname);
+    pdu_unmarshal(copdu->pdu, offset, "dsdd", &fid, &name, &mode, &gid);
 
-    fidp = lookup_fid(s, fid);
+    fidp = lookup_fid(copdu->s, fid);
     if (fidp == NULL) {
         err = -ENOENT;
         goto out;
     }
-    v9fs_string_sprintf(&vs->fullname, "%s/%s", fidp->path.data, 
vs->name.data);
-    err = v9fs_do_mkdir(s, vs->fullname.data, mode, fidp->uid, gid);
+    v9fs_string_sprintf(&fullname, "%s/%s", fidp->path.data, name.data);
+    err = v9fs_do_mkdir(copdu->s, fullname.data, mode, fidp->uid, gid);
     if (err == -1) {
         err = -errno;
         goto out;
     }
-    err = v9fs_do_lstat(s, &vs->fullname, &vs->stbuf);
+    err = v9fs_do_lstat(copdu->s, &fullname, &stbuf);
     if (err == -1) {
         err = -errno;
         goto out;
     }
-    stat_to_qid(&vs->stbuf, &vs->qid);
-    vs->offset += pdu_marshal(vs->pdu, vs->offset, "Q", &vs->qid);
-    err = vs->offset;
+    stat_to_qid(&stbuf, &qid);
+    offset += pdu_marshal(copdu->pdu, offset, "Q", &qid);
+    err = offset;
 out:
-    complete_pdu(s, vs->pdu, err);
-    v9fs_string_free(&vs->fullname);
-    v9fs_string_free(&vs->name);
-    qemu_free(vs);
+    complete_pdu(copdu->s, copdu->pdu, err);
+    v9fs_string_free(&fullname);
+    v9fs_string_free(&name);
     qemu_free(copdu);
 }
 
-- 
1.7.1




reply via email to

[Prev in Thread] Current Thread [Next in Thread]