diff options
author | Anthony Liguori <aliguori@us.ibm.com> | 2010-04-29 17:44:53 +0530 |
---|---|---|
committer | Anthony Liguori <aliguori@us.ibm.com> | 2010-05-03 12:17:38 -0500 |
commit | 4da7d3fa2d9ad02bdf8abfc741bb882f1f5c482a (patch) | |
tree | 8dfe80f4141ee78fc4540750981ce002d8da8b27 /hw/virtio-9p.c | |
parent | 955efc47559fb4475d06a37ce0ab3f3ae8c4cd83 (diff) | |
download | qemu-4da7d3fa2d9ad02bdf8abfc741bb882f1f5c482a.zip qemu-4da7d3fa2d9ad02bdf8abfc741bb882f1f5c482a.tar.gz qemu-4da7d3fa2d9ad02bdf8abfc741bb882f1f5c482a.tar.bz2 |
virtio-9p: Add P9_TSTAT support
Implement P9_TSTAT support. This get the mount to work on the guest.
[kiran@linux.vnet.ibm.com: malloc to qemu_malloc conversion]
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Diffstat (limited to 'hw/virtio-9p.c')
-rw-r--r-- | hw/virtio-9p.c | 55 |
1 files changed, 53 insertions, 2 deletions
diff --git a/hw/virtio-9p.c b/hw/virtio-9p.c index 48b5e83..f9d1c55 100644 --- a/hw/virtio-9p.c +++ b/hw/virtio-9p.c @@ -895,11 +895,62 @@ out: v9fs_string_free(&aname); } +typedef struct V9fsStatState { + V9fsPDU *pdu; + size_t offset; + V9fsStat v9stat; + V9fsFidState *fidp; + struct stat stbuf; +} V9fsStatState; + +static void v9fs_stat_post_lstat(V9fsState *s, V9fsStatState *vs, int err) +{ + if (err == -1) { + err = -errno; + goto out; + } + + err = stat_to_v9stat(s, &vs->fidp->path, &vs->stbuf, &vs->v9stat); + if (err) { + goto out; + } + vs->offset += pdu_marshal(vs->pdu, vs->offset, "wS", 0, &vs->v9stat); + err = vs->offset; + +out: + complete_pdu(s, vs->pdu, err); + v9fs_stat_free(&vs->v9stat); + qemu_free(vs); +} + static void v9fs_stat(V9fsState *s, V9fsPDU *pdu) { - if (debug_9p_pdu) { - pprint_pdu(pdu); + int32_t fid; + V9fsStatState *vs; + ssize_t err = 0; + + vs = qemu_malloc(sizeof(*vs)); + vs->pdu = pdu; + vs->offset = 7; + + memset(&vs->v9stat, 0, sizeof(vs->v9stat)); + + pdu_unmarshal(vs->pdu, vs->offset, "d", &fid); + + vs->fidp = lookup_fid(s, fid); + if (vs->fidp == NULL) { + err = -ENOENT; + goto out; } + + err = v9fs_do_lstat(s, &vs->fidp->path, &vs->stbuf); + v9fs_stat_post_lstat(s, vs, err); + return; + +out: + complete_pdu(s, vs->pdu, err); + v9fs_stat_free(&vs->v9stat); + qemu_free(vs); } static void v9fs_walk(V9fsState *s, V9fsPDU *pdu) |