From patchwork Mon Jun 28 21:55:05 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: jvrao X-Patchwork-Id: 57206 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 BE433B6EE9 for ; Tue, 29 Jun 2010 08:09:21 +1000 (EST) Received: from localhost ([127.0.0.1]:44875 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OTMVy-0007Gl-GF for incoming@patchwork.ozlabs.org; Mon, 28 Jun 2010 18:09:18 -0400 Received: from [140.186.70.92] (port=59172 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OTMFC-00059n-7E for qemu-devel@nongnu.org; Mon, 28 Jun 2010 17:52:01 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OTMF8-0006sF-Ia for qemu-devel@nongnu.org; Mon, 28 Jun 2010 17:51:57 -0400 Received: from e36.co.us.ibm.com ([32.97.110.154]:45963) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OTMF8-0006s1-CA for qemu-devel@nongnu.org; Mon, 28 Jun 2010 17:51:54 -0400 Received: from d03relay03.boulder.ibm.com (d03relay03.boulder.ibm.com [9.17.195.228]) by e36.co.us.ibm.com (8.14.4/8.13.1) with ESMTP id o5SLmR2Q028223 for ; Mon, 28 Jun 2010 15:48:27 -0600 Received: from d03av02.boulder.ibm.com (d03av02.boulder.ibm.com [9.17.195.168]) by d03relay03.boulder.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id o5SLpdbk089590 for ; Mon, 28 Jun 2010 15:51:43 -0600 Received: from d03av02.boulder.ibm.com (loopback [127.0.0.1]) by d03av02.boulder.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id o5SLpdEC026552 for ; Mon, 28 Jun 2010 15:51:39 -0600 Received: from localhost.localdomain (elm9m80.beaverton.ibm.com [9.47.81.80]) by d03av02.boulder.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with ESMTP id o5SLpX84026203; Mon, 28 Jun 2010 15:51:38 -0600 From: "Venkateswararao Jujjuri (JV)" To: qemu-devel@nongnu.org Date: Mon, 28 Jun 2010 14:55:05 -0700 Message-Id: <1277762117-11212-8-git-send-email-jvrao@linux.vnet.ibm.com> X-Mailer: git-send-email 1.6.0.6 In-Reply-To: <1277762117-11212-1-git-send-email-jvrao@linux.vnet.ibm.com> References: <1277762117-11212-1-git-send-email-jvrao@linux.vnet.ibm.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6, seldom 2.4 (older, 4) Cc: aliguori@us.ibm.com, Sripathi Kodi , Venkateswararao Jujjuri Subject: [Qemu-devel] [PATCH 08/20] [virtio-9p] Make v9fs_do_utimensat accept timespec structures instead of v9stat. 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: Sripathi Kodi Currently v9fs_do_utimensat takes a V9fsStat argument and builds timespec structures. It sets tv_nsec values to 0 by default. Instead of this it should take struct timespec[2] and pass it down to the system directly. This will make it more generic and useful elsewhere. Signed-off-by: Sripathi Kodi Signed-off-by: Venkateswararao Jujjuri --- hw/virtio-9p.c | 37 ++++++++++++++++++------------------- 1 files changed, 18 insertions(+), 19 deletions(-) diff --git a/hw/virtio-9p.c b/hw/virtio-9p.c index 099514a..613abcd 100644 --- a/hw/virtio-9p.c +++ b/hw/virtio-9p.c @@ -237,25 +237,10 @@ static int v9fs_do_chown(V9fsState *s, V9fsString *path, uid_t uid, gid_t gid) return s->ops->chown(&s->ctx, path->data, &cred); } -static int v9fs_do_utimensat(V9fsState *s, V9fsString *path, V9fsStat v9stat) +static int v9fs_do_utimensat(V9fsState *s, V9fsString *path, + const struct timespec times[2]) { - struct timespec ts[2]; - - if (v9stat.atime != -1) { - ts[0].tv_sec = v9stat.atime; - ts[0].tv_nsec = 0; - } else { - ts[0].tv_nsec = UTIME_OMIT; - } - - if (v9stat.mtime != -1) { - ts[1].tv_sec = v9stat.mtime; - ts[1].tv_nsec = 0; - } else { - ts[1].tv_nsec = UTIME_OMIT; - } - - return s->ops->utimensat(&s->ctx, path->data, ts); + return s->ops->utimensat(&s->ctx, path->data, times); } static int v9fs_do_remove(V9fsState *s, V9fsString *path) @@ -2312,7 +2297,21 @@ static void v9fs_wstat_post_chmod(V9fsState *s, V9fsWstatState *vs, int err) } if (vs->v9stat.mtime != -1 || vs->v9stat.atime != -1) { - if (v9fs_do_utimensat(s, &vs->fidp->path, vs->v9stat)) { + struct timespec times[2]; + if (vs->v9stat.atime != -1) { + times[0].tv_sec = vs->v9stat.atime; + times[0].tv_nsec = 0; + } else { + times[0].tv_nsec = UTIME_OMIT; + } + if (vs->v9stat.mtime != -1) { + times[1].tv_sec = vs->v9stat.mtime; + times[1].tv_nsec = 0; + } else { + times[1].tv_nsec = UTIME_OMIT; + } + + if (v9fs_do_utimensat(s, &vs->fidp->path, times)) { err = -errno; } }