From patchwork Wed Jul 21 16:04:43 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: jvrao X-Patchwork-Id: 59478 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 93A9BB70A9 for ; Thu, 22 Jul 2010 02:45:00 +1000 (EST) Received: from localhost ([127.0.0.1]:50439 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1ObcPf-0004Lo-S8 for incoming@patchwork.ozlabs.org; Wed, 21 Jul 2010 12:44:55 -0400 Received: from [140.186.70.92] (port=54114 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Obbkt-00028h-9N for qemu-devel@nongnu.org; Wed, 21 Jul 2010 12:02:52 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1Obbkh-0000G9-Mb for qemu-devel@nongnu.org; Wed, 21 Jul 2010 12:02:46 -0400 Received: from e2.ny.us.ibm.com ([32.97.182.142]:49811) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Obbkh-0000G2-Jz for qemu-devel@nongnu.org; Wed, 21 Jul 2010 12:02:35 -0400 Received: from d01relay01.pok.ibm.com (d01relay01.pok.ibm.com [9.56.227.233]) by e2.ny.us.ibm.com (8.14.4/8.13.1) with ESMTP id o6LFn4gg028553 for ; Wed, 21 Jul 2010 11:49:04 -0400 Received: from d03av02.boulder.ibm.com (d03av02.boulder.ibm.com [9.17.195.168]) by d01relay01.pok.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id o6LG2Whx288984 for ; Wed, 21 Jul 2010 12:02:34 -0400 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 o6LG2IlV016984 for ; Wed, 21 Jul 2010 10:02:19 -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 o6LG25RW015184; Wed, 21 Jul 2010 10:02:14 -0600 From: "Venkateswararao Jujjuri (JV)" To: qemu-devel@nongnu.org Date: Wed, 21 Jul 2010 09:04:43 -0700 Message-Id: <1279728299-28482-9-git-send-email-jvrao@linux.vnet.ibm.com> X-Mailer: git-send-email 1.6.0.6 In-Reply-To: <1279728299-28482-1-git-send-email-jvrao@linux.vnet.ibm.com> References: <1279728299-28482-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-V2 08/24] [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 bb59c0c..e4754b8 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) @@ -2342,7 +2327,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; } }