diff options
author | Venkateswararao Jujjuri <jvrao@linux.vnet.ibm.com> | 2011-08-09 00:00:01 +0530 |
---|---|---|
committer | Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com> | 2011-08-22 09:44:29 +0530 |
commit | 3fa2a8d1cd5794dd20c5bdb71e5a6db4b6f8eb4f (patch) | |
tree | 51de8e67dcacd412a4b014a1a9eb0a4ad757ed3e | |
parent | 02ac7a34ff124b8d41dc1afadf622b07fa292b48 (diff) | |
download | qemu-3fa2a8d1cd5794dd20c5bdb71e5a6db4b6f8eb4f.zip qemu-3fa2a8d1cd5794dd20c5bdb71e5a6db4b6f8eb4f.tar.gz qemu-3fa2a8d1cd5794dd20c5bdb71e5a6db4b6f8eb4f.tar.bz2 |
hw/9pfs: Update v9fs_symlink to use coroutines
Signed-off-by: Venkateswararao Jujjuri <jvrao@linux.vnet.ibm.com>
Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
-rw-r--r-- | hw/9pfs/virtio-9p.c | 92 | ||||
-rw-r--r-- | hw/9pfs/virtio-9p.h | 12 |
2 files changed, 28 insertions, 76 deletions
diff --git a/hw/9pfs/virtio-9p.c b/hw/9pfs/virtio-9p.c index 1659e8c..203c031 100644 --- a/hw/9pfs/virtio-9p.c +++ b/hw/9pfs/virtio-9p.c @@ -117,18 +117,6 @@ static int v9fs_do_chmod(V9fsState *s, V9fsString *path, mode_t mode) return s->ops->chmod(&s->ctx, path->data, &cred); } -static int v9fs_do_symlink(V9fsState *s, V9fsFidState *fidp, - const char *oldpath, const char *newpath, gid_t gid) -{ - FsCred cred; - cred_init(&cred); - cred.fc_uid = fidp->uid; - cred.fc_gid = gid; - cred.fc_mode = 0777; - - return s->ops->symlink(&s->ctx, oldpath, newpath, &cred); -} - static int v9fs_do_link(V9fsState *s, V9fsString *oldpath, V9fsString *newpath) { return s->ops->link(&s->ctx, oldpath->data, newpath->data); @@ -2029,10 +2017,9 @@ static void v9fs_create(void *opaque) } fidp->fid_type = P9_FID_DIR; } else if (perm & P9_STAT_MODE_SYMLINK) { - err = v9fs_do_symlink(pdu->s, fidp, extension.data, + err = v9fs_co_symlink(pdu->s, fidp, extension.data, fullname.data, -1); if (err < 0) { - err = -errno; goto out; } } else if (perm & P9_STAT_MODE_LINK) { @@ -2115,69 +2102,46 @@ out: v9fs_string_free(&fullname); } -static void v9fs_post_symlink(V9fsState *s, V9fsSymlinkState *vs, int err) -{ - if (err == 0) { - stat_to_qid(&vs->stbuf, &vs->qid); - vs->offset += pdu_marshal(vs->pdu, vs->offset, "Q", &vs->qid); - err = vs->offset; - } else { - err = -errno; - } - complete_pdu(s, vs->pdu, err); - v9fs_string_free(&vs->name); - v9fs_string_free(&vs->symname); - v9fs_string_free(&vs->fullname); - g_free(vs); -} - -static void v9fs_symlink_post_do_symlink(V9fsState *s, V9fsSymlinkState *vs, - int err) -{ - if (err) { - goto out; - } - err = v9fs_do_lstat(s, &vs->fullname, &vs->stbuf); -out: - v9fs_post_symlink(s, vs, err); -} - static void v9fs_symlink(void *opaque) { V9fsPDU *pdu = opaque; - V9fsState *s = pdu->s; + V9fsString name; + V9fsString symname; + V9fsString fullname; + V9fsFidState *dfidp; + V9fsQID qid; + struct stat stbuf; int32_t dfid; - V9fsSymlinkState *vs; int err = 0; gid_t gid; + size_t offset = 7; - vs = g_malloc(sizeof(*vs)); - vs->pdu = pdu; - vs->offset = 7; - - v9fs_string_init(&vs->fullname); - - pdu_unmarshal(vs->pdu, vs->offset, "dssd", &dfid, &vs->name, - &vs->symname, &gid); + v9fs_string_init(&fullname); + pdu_unmarshal(pdu, offset, "dssd", &dfid, &name, &symname, &gid); - vs->dfidp = lookup_fid(s, dfid); - if (vs->dfidp == NULL) { + dfidp = lookup_fid(pdu->s, dfid); + if (dfidp == NULL) { err = -EINVAL; goto out; } - v9fs_string_sprintf(&vs->fullname, "%s/%s", vs->dfidp->path.data, - vs->name.data); - err = v9fs_do_symlink(s, vs->dfidp, vs->symname.data, - vs->fullname.data, gid); - v9fs_symlink_post_do_symlink(s, vs, err); - return; - + v9fs_string_sprintf(&fullname, "%s/%s", dfidp->path.data, name.data); + err = v9fs_co_symlink(pdu->s, dfidp, symname.data, fullname.data, gid); + if (err < 0) { + goto out; + } + err = v9fs_co_lstat(pdu->s, &fullname, &stbuf); + if (err < 0) { + goto out; + } + stat_to_qid(&stbuf, &qid); + offset += pdu_marshal(pdu, offset, "Q", &qid); + err = offset; out: - complete_pdu(s, vs->pdu, err); - v9fs_string_free(&vs->name); - v9fs_string_free(&vs->symname); - g_free(vs); + complete_pdu(pdu->s, pdu, err); + v9fs_string_free(&name); + v9fs_string_free(&symname); + v9fs_string_free(&fullname); } static void v9fs_flush(void *opaque) diff --git a/hw/9pfs/virtio-9p.h b/hw/9pfs/virtio-9p.h index e7d87d9..29f3184 100644 --- a/hw/9pfs/virtio-9p.h +++ b/hw/9pfs/virtio-9p.h @@ -305,18 +305,6 @@ typedef struct V9fsWstatState struct stat stbuf; } V9fsWstatState; -typedef struct V9fsSymlinkState -{ - V9fsPDU *pdu; - size_t offset; - V9fsString name; - V9fsString symname; - V9fsString fullname; - V9fsFidState *dfidp; - V9fsQID qid; - struct stat stbuf; -} V9fsSymlinkState; - typedef struct V9fsIattr { int32_t valid; |