[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 17/29] [virtio-9p] Remove post functions for v9fs_cr
From: |
Venkateswararao Jujjuri (JV) |
Subject: |
[Qemu-devel] [PATCH 17/29] [virtio-9p] Remove post functions for v9fs_create |
Date: |
Wed, 25 May 2011 16:53:05 -0700 |
Signed-off-by: Venkateswararao Jujjuri "<address@hidden>
---
hw/9pfs/virtio-9p.c | 229 ++++++++++++++++-----------------------------------
1 files changed, 72 insertions(+), 157 deletions(-)
diff --git a/hw/9pfs/virtio-9p.c b/hw/9pfs/virtio-9p.c
index d1733ca..14eefac 100644
--- a/hw/9pfs/virtio-9p.c
+++ b/hw/9pfs/virtio-9p.c
@@ -134,11 +134,6 @@ static int v9fs_do_mknod(V9fsState *s, char *name,
return s->ops->mknod(&s->ctx, name, &cred);
}
-static int v9fs_do_fstat(V9fsState *s, int fd, struct stat *stbuf)
-{
- return s->ops->fstat(&s->ctx, fd, stbuf);
-}
-
static int v9fs_do_symlink(V9fsState *s, V9fsFidState *fidp,
const char *oldpath, const char *newpath, gid_t gid)
{
@@ -2005,137 +2000,66 @@ out:
qemu_free(vs);
}
-static void v9fs_create_post_getiounit(V9fsState *s, V9fsCreateState *vs)
-{
- int err;
- v9fs_string_copy(&vs->fidp->path, &vs->fullname);
- stat_to_qid(&vs->stbuf, &vs->qid);
-
- vs->offset += pdu_marshal(vs->pdu, vs->offset, "Qd", &vs->qid, vs->iounit);
- err = vs->offset;
-
- complete_pdu(s, vs->pdu, err);
- v9fs_string_free(&vs->name);
- v9fs_string_free(&vs->extension);
- v9fs_string_free(&vs->fullname);
- qemu_free(vs);
-}
-
-static void v9fs_post_create(V9fsState *s, V9fsCreateState *vs, int err)
-{
- if (err == 0) {
- vs->iounit = get_iounit(s, &vs->fidp->path);
- v9fs_create_post_getiounit(s, vs);
- return;
- }
-
- complete_pdu(s, vs->pdu, err);
- v9fs_string_free(&vs->name);
- v9fs_string_free(&vs->extension);
- v9fs_string_free(&vs->fullname);
- qemu_free(vs);
-}
-
-static void v9fs_create_post_perms(V9fsState *s, V9fsCreateState *vs, int err)
-{
- if (err) {
- err = -errno;
- }
- v9fs_post_create(s, vs, err);
-}
-
-static void v9fs_create_post_opendir(V9fsState *s, V9fsCreateState *vs,
- int err)
+static void v9fs_create(void *opaque)
{
- if (!vs->fidp->fs.dir) {
- err = -errno;
- }
- vs->fidp->fid_type = P9_FID_DIR;
- v9fs_post_create(s, vs, err);
-}
+ int err = 0;
+ int32_t fid;
+ V9fsCreateState *vs;
+ V9fsPDU *pdu = opaque;
+ V9fsState *s = pdu->s;
-static void v9fs_create_post_dir_lstat(V9fsState *s, V9fsCreateState *vs,
- int err)
-{
- if (err) {
- err = -errno;
- goto out;
- }
+ vs = qemu_malloc(sizeof(*vs));
+ vs->pdu = pdu;
+ vs->offset = 7;
- vs->fidp->fs.dir = v9fs_do_opendir(s, &vs->fullname);
- v9fs_create_post_opendir(s, vs, err);
- return;
+ v9fs_string_init(&vs->fullname);
-out:
- v9fs_post_create(s, vs, err);
-}
+ pdu_unmarshal(vs->pdu, vs->offset, "dsdbs", &fid, &vs->name,
+ &vs->perm, &vs->mode, &vs->extension);
-static void v9fs_create_post_mkdir(V9fsState *s, V9fsCreateState *vs, int err)
-{
- if (err < 0) {
+ vs->fidp = lookup_fid(s, fid);
+ if (vs->fidp == NULL) {
+ err = -EINVAL;
goto out;
}
+ v9fs_string_sprintf(&vs->fullname, "%s/%s", vs->fidp->path.data,
+ vs->name.data);
err = v9fs_do_lstat(s, &vs->fullname, &vs->stbuf);
- v9fs_create_post_dir_lstat(s, vs, err);
- return;
-
-out:
- v9fs_post_create(s, vs, err);
-}
-
-static void v9fs_create_post_fstat(V9fsState *s, V9fsCreateState *vs, int err)
-{
- if (err) {
- vs->fidp->fid_type = P9_FID_NONE;
- close(vs->fidp->fs.fd);
- err = -errno;
- }
- v9fs_post_create(s, vs, err);
- return;
-}
-
-static void v9fs_create_post_open2(V9fsState *s, V9fsCreateState *vs, int err)
-{
- if (err < 0) {
- goto out;
- }
- vs->fidp->fid_type = P9_FID_FILE;
- err = v9fs_do_fstat(s, vs->fidp->fs.fd, &vs->stbuf);
- v9fs_create_post_fstat(s, vs, err);
-
- return;
-
-out:
- v9fs_post_create(s, vs, err);
-
-}
-
-static void v9fs_create_post_lstat(V9fsState *s, V9fsCreateState *vs, int err)
-{
-
if (err == 0 || errno != ENOENT) {
err = -errno;
goto out;
}
-
if (vs->perm & P9_STAT_MODE_DIR) {
err = v9fs_co_mkdir(s, vs->fullname.data, vs->perm & 0777,
vs->fidp->uid, -1);
- v9fs_create_post_mkdir(s, vs, err);
+ if (!err) {
+ vs->fidp->fs.dir = v9fs_do_opendir(s, &vs->fullname);
+ }
+ if (err < 0 || !vs->fidp->fs.dir) {
+ err = -errno;
+ vs->fidp->fid_type = P9_FID_NONE;
+ }
+ vs->fidp->fid_type = P9_FID_DIR;
} else if (vs->perm & P9_STAT_MODE_SYMLINK) {
err = v9fs_do_symlink(s, vs->fidp, vs->extension.data,
vs->fullname.data, -1);
- v9fs_create_post_perms(s, vs, err);
+ if (err < 0) {
+ err = -errno;
+ goto out;
+ }
} else if (vs->perm & P9_STAT_MODE_LINK) {
int32_t nfid = atoi(vs->extension.data);
V9fsFidState *nfidp = lookup_fid(s, nfid);
if (nfidp == NULL) {
- err = -errno;
- v9fs_post_create(s, vs, err);
+ err = -EINVAL;
+ goto out;
}
err = v9fs_do_link(s, &nfidp->path, &vs->fullname);
- v9fs_create_post_perms(s, vs, err);
+ if (err < 0) {
+ err = -errno;
+ goto out;
+ }
} else if (vs->perm & P9_STAT_MODE_DEVICE) {
char ctype;
uint32_t major, minor;
@@ -2144,7 +2068,7 @@ static void v9fs_create_post_lstat(V9fsState *s,
V9fsCreateState *vs, int err)
if (sscanf(vs->extension.data, "%c %u %u", &ctype, &major,
&minor) != 3) {
err = -errno;
- v9fs_post_create(s, vs, err);
+ goto out;
}
switch (ctype) {
@@ -2156,69 +2080,60 @@ static void v9fs_create_post_lstat(V9fsState *s,
V9fsCreateState *vs, int err)
break;
default:
err = -EIO;
- v9fs_post_create(s, vs, err);
+ goto out;
}
nmode |= vs->perm & 0777;
err = v9fs_do_mknod(s, vs->fullname.data, nmode,
makedev(major, minor), vs->fidp->uid, -1);
- v9fs_create_post_perms(s, vs, err);
+ if (err < 0) {
+ err = -errno;
+ goto out;
+ }
} else if (vs->perm & P9_STAT_MODE_NAMED_PIPE) {
err = v9fs_do_mknod(s, vs->fullname.data, S_IFIFO | (vs->perm & 0777),
0, vs->fidp->uid, -1);
- v9fs_post_create(s, vs, err);
+ if (err < 0) {
+ err = -errno;
+ goto out;
+ }
} else if (vs->perm & P9_STAT_MODE_SOCKET) {
err = v9fs_do_mknod(s, vs->fullname.data, S_IFSOCK | (vs->perm & 0777),
0, vs->fidp->uid, -1);
- v9fs_post_create(s, vs, err);
+ if (err < 0) {
+ err = -errno;
+ goto out;
+ }
} else {
err = v9fs_co_open2(s, vs->fidp, vs->fullname.data, -1,
- omode_to_uflags(vs->mode)|O_CREAT, vs->perm);
-
- v9fs_create_post_open2(s, vs, err);
+ omode_to_uflags(vs->mode)|O_CREAT, vs->perm);
+ if (err < 0) {
+ err = -errno;
+ goto out;
+ }
+ vs->fidp->fid_type = P9_FID_FILE;
}
-
- return;
-
-out:
- v9fs_post_create(s, vs, err);
-}
-
-static void v9fs_create(void *opaque)
-{
- V9fsPDU *pdu = opaque;
- V9fsState *s = pdu->s;
- int32_t fid;
- V9fsCreateState *vs;
- 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, "dsdbs", &fid, &vs->name,
- &vs->perm, &vs->mode, &vs->extension);
-
- vs->fidp = lookup_fid(s, fid);
- if (vs->fidp == NULL) {
- err = -EINVAL;
+ err = v9fs_do_lstat(s, &vs->fullname, &vs->stbuf);
+ if (err < 0) {
+ err = -errno;
+ vs->fidp->fid_type = P9_FID_NONE;
+ if (vs->fidp->fs.fd) {
+ close(vs->fidp->fs.fd);
+ }
goto out;
}
-
- v9fs_string_sprintf(&vs->fullname, "%s/%s", vs->fidp->path.data,
- vs->name.data);
-
- err = v9fs_do_lstat(s, &vs->fullname, &vs->stbuf);
- v9fs_create_post_lstat(s, vs, err);
- return;
+ vs->iounit = get_iounit(s, &vs->fidp->path);
+ v9fs_string_copy(&vs->fidp->path, &vs->fullname);
+ stat_to_qid(&vs->stbuf, &vs->qid);
+ vs->offset += pdu_marshal(vs->pdu, vs->offset, "Qd", &vs->qid, vs->iounit);
+ err = vs->offset;
out:
- complete_pdu(s, vs->pdu, err);
- v9fs_string_free(&vs->name);
- v9fs_string_free(&vs->extension);
- qemu_free(vs);
+ complete_pdu(s, vs->pdu, err);
+ v9fs_string_free(&vs->name);
+ v9fs_string_free(&vs->extension);
+ v9fs_string_free(&vs->fullname);
+ qemu_free(vs);
}
static void v9fs_post_symlink(V9fsState *s, V9fsSymlinkState *vs, int err)
--
1.7.1
- [Qemu-devel] [PATCH 01/29] hw/9pfs: Add yeild support to rename coroutine, (continued)
- [Qemu-devel] [PATCH 01/29] hw/9pfs: Add yeild support to rename coroutine, Venkateswararao Jujjuri (JV), 2011/05/25
- [Qemu-devel] [PATCH 04/29] hw/9pfs: Update v9fs_lock to use coroutines, Venkateswararao Jujjuri (JV), 2011/05/25
- [Qemu-devel] [PATCH 09/29] [virtio-9p] clean up v9fs_lcreate, Venkateswararao Jujjuri (JV), 2011/05/25
- [Qemu-devel] [PATCH 05/29] hw/9pfs: Update v9fs_getlock to use coroutines, Venkateswararao Jujjuri (JV), 2011/05/25
- [Qemu-devel] [PATCH 14/29] hw/9pfs: Update v9fs_clunk to use coroutines, Venkateswararao Jujjuri (JV), 2011/05/25
- [Qemu-devel] [PATCH 07/29] hw/9pfs: Update v9fs_open to use coroutines, Venkateswararao Jujjuri (JV), 2011/05/25
- [Qemu-devel] [PATCH 16/29] hw/9pfs: Update v9fs_fsync to use coroutines, Venkateswararao Jujjuri (JV), 2011/05/25
- [Qemu-devel] [PATCH 22/29] [virtio-9p] coroutine and threading for v9fs_do_link, Venkateswararao Jujjuri (JV), 2011/05/25
- [Qemu-devel] [PATCH 10/29] [PATCH] [virtio-9p] coroutine and threading for open2, Venkateswararao Jujjuri (JV), 2011/05/25
- [Qemu-devel] [PATCH 12/29] hw/9pfs: Update v9fs_walk to use coroutines, Venkateswararao Jujjuri (JV), 2011/05/25
- [Qemu-devel] [PATCH 17/29] [virtio-9p] Remove post functions for v9fs_create,
Venkateswararao Jujjuri (JV) <=
- [Qemu-devel] [PATCH 20/29] [virtio-9p] clean up v9fs_symlink, Venkateswararao Jujjuri (JV), 2011/05/25
- [Qemu-devel] [PATCH 19/29] [virtio-9p] Remove post functions for v9fs_symlink, Venkateswararao Jujjuri (JV), 2011/05/25
- [Qemu-devel] [PATCH 18/29] [virtio-9p] clean up v9fs_create Rearrange the code, Venkateswararao Jujjuri (JV), 2011/05/25
- [Qemu-devel] [PATCH 27/29] hw/9pfs: Add yield support for preadv coroutine, Venkateswararao Jujjuri (JV), 2011/05/25
- [Qemu-devel] [PATCH 11/29] hw/9pfs: Update v9fs_stat to use coroutines, Venkateswararao Jujjuri (JV), 2011/05/25
- [Qemu-devel] [PATCH 08/29] [virtio-9p] Remove post functions for v9fs_lcreate, Venkateswararao Jujjuri (JV), 2011/05/25
- [Qemu-devel] [PATCH 23/29] hw/9pfs: Add yield support for pwritev coroutine, Venkateswararao Jujjuri (JV), 2011/05/25
- [Qemu-devel] [PATCH 21/29] [virtio-9p] coroutine and threading for v9fs_do_symlink, Venkateswararao Jujjuri (JV), 2011/05/25
- [Qemu-devel] [PATCH 13/29] hw/9pfs: Add yeild support for clunk related coroutine, Venkateswararao Jujjuri (JV), 2011/05/25
- [Qemu-devel] [PATCH 29/29] use readdir_r instead of readdir for reentrancy, Venkateswararao Jujjuri (JV), 2011/05/25