From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from [140.186.70.92] (port=43572 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OrFTE-0004FK-MI for qemu-devel@nongnu.org; Thu, 02 Sep 2010 15:29:14 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OrFTA-0004bb-JC for qemu-devel@nongnu.org; Thu, 02 Sep 2010 15:29:12 -0400 Received: from e3.ny.us.ibm.com ([32.97.182.143]:53021) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OrFTA-0004bQ-Dq for qemu-devel@nongnu.org; Thu, 02 Sep 2010 15:29:08 -0400 Received: from d01relay04.pok.ibm.com (d01relay04.pok.ibm.com [9.56.227.236]) by e3.ny.us.ibm.com (8.14.4/8.13.1) with ESMTP id o82JDXA5019862 for ; Thu, 2 Sep 2010 15:13:33 -0400 Received: from d03av02.boulder.ibm.com (d03av02.boulder.ibm.com [9.17.195.168]) by d01relay04.pok.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id o82JT7aS106960 for ; Thu, 2 Sep 2010 15:29:07 -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 o82JT6I9021366 for ; Thu, 2 Sep 2010 13:29:07 -0600 From: "Venkateswararao Jujjuri (JV)" Date: Thu, 2 Sep 2010 12:39:28 -0700 Message-Id: <1283456388-13083-9-git-send-email-jvrao@linux.vnet.ibm.com> In-Reply-To: <1283456388-13083-1-git-send-email-jvrao@linux.vnet.ibm.com> References: <1283456388-13083-1-git-send-email-jvrao@linux.vnet.ibm.com> Subject: [Qemu-devel] [PATCH -V5 08/28] [virtio-9p] Make v9fs_do_utimensat accept timespec structures instead of v9stat. List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: aliguori@us.ibm.com, Sripathi Kodi , Venkateswararao Jujjuri 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 bd6cba9..687f63d 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) @@ -2341,7 +2326,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; } } -- 1.6.5.2