From patchwork Thu Apr 29 12:14:53 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Aneesh Kumar K.V" X-Patchwork-Id: 51281 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 0AFDDB7D17 for ; Thu, 29 Apr 2010 22:40:11 +1000 (EST) Received: from localhost ([127.0.0.1]:58255 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1O7T16-0003kl-4n for incoming@patchwork.ozlabs.org; Thu, 29 Apr 2010 08:38:56 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1O7Sem-0005ja-7F for qemu-devel@nongnu.org; Thu, 29 Apr 2010 08:15:52 -0400 Received: from [140.186.70.92] (port=45888 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1O7Sej-0005i9-Kn for qemu-devel@nongnu.org; Thu, 29 Apr 2010 08:15:50 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1O7Sei-0006to-2T for qemu-devel@nongnu.org; Thu, 29 Apr 2010 08:15:49 -0400 Received: from e23smtp03.au.ibm.com ([202.81.31.145]:56980) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1O7Seh-0006tV-HN for qemu-devel@nongnu.org; Thu, 29 Apr 2010 08:15:48 -0400 Received: from d23relay05.au.ibm.com (d23relay05.au.ibm.com [202.81.31.247]) by e23smtp03.au.ibm.com (8.14.3/8.13.1) with ESMTP id o3TCCR2K013594 for ; Thu, 29 Apr 2010 22:12:27 +1000 Received: from d23av04.au.ibm.com (d23av04.au.ibm.com [9.190.235.139]) by d23relay05.au.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id o3TC8tT51609920 for ; Thu, 29 Apr 2010 22:08:55 +1000 Received: from d23av04.au.ibm.com (loopback [127.0.0.1]) by d23av04.au.ibm.com (8.14.3/8.13.1/NCO v10.0 AVout) with ESMTP id o3TCFjpF020645 for ; Thu, 29 Apr 2010 22:15:45 +1000 Received: from skywalker.in.ibm.com ([9.124.222.113]) by d23av04.au.ibm.com (8.14.3/8.13.1/NCO v10.0 AVin) with ESMTP id o3TCF898018931; Thu, 29 Apr 2010 22:15:43 +1000 From: "Aneesh Kumar K.V" To: qemu-devel@nongnu.org Date: Thu, 29 Apr 2010 17:44:53 +0530 Message-Id: <1272543303-9830-12-git-send-email-aneesh.kumar@linux.vnet.ibm.com> X-Mailer: git-send-email 1.7.0.4.360.g11766c In-Reply-To: <1272543303-9830-1-git-send-email-aneesh.kumar@linux.vnet.ibm.com> References: <1272543303-9830-1-git-send-email-aneesh.kumar@linux.vnet.ibm.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6, seldom 2.4 (older, 4) Cc: ericvh@gmail.com, aliguori@us.ibm.com, jvrao@linux.vnet.ibm.com, aneesh.kumar@linux.vnet.ibm.com Subject: [Qemu-devel] [PATCH -V6 11/21] virtio-9p: Add P9_TSTAT support X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Anthony Liguori 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 Signed-off-by: Aneesh Kumar K.V --- 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)