Received: from [140.186.70.92] (port=43792 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PHVbz-0004U7-79 for qemu-devel@nongnu.org; Sun, 14 Nov 2010 00:58:49 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PHVbv-0006so-7n for qemu-devel@nongnu.org; Sun, 14 Nov 2010 00:58:47 -0500 Received: from sous-sol.org ([216.99.217.87]:50895 helo=sequoia.sous-sol.org) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PHVbu-0006sc-KI for qemu-devel@nongnu.org; Sun, 14 Nov 2010 00:58:43 -0500 Date: Sat, 13 Nov 2010 21:58:22 -0800 From: Chris Wright Message-ID: <20101114055822.GE25164@sequoia.sous-sol.org> References: <4CB56715.7080605@jp.fujitsu.com> <4CB64FF6.5080906@jp.fujitsu.com> <20101104170303.GE15211@sequoia.sous-sol.org> <4CD3A513.2010102@jp.fujitsu.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <4CD3A513.2010102@jp.fujitsu.com> Subject: [Qemu-devel] Re: [PATCH] virtio-9p: fix build on !CONFIG_UTIMENSAT v2 List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Hidetoshi Seto Cc: Blue Swirl , "kvm@vger.kernel.org" , "Hao, Xudong" , "qemu-devel@nongnu.org" , Chris Wright , Avi Kivity * Hidetoshi Seto (seto.hidetoshi@jp.fujitsu.com) wrote: > + /* > + * Fallback: use utimes() instead of utimensat(). > + * See commit 74bc02b2d2272dc88fb98d43e631eb154717f517 for known problem. > + */ > + struct timeval tv[2]; > + int i; > + > + for (i = 0; i < 2; i++) { > + if (times[i].tv_nsec == UTIME_OMIT || times[i].tv_nsec == UTIME_NOW) { > + tv[i].tv_sec = 0; > + tv[i].tv_usec = 0; I don't think this is accurate in either case. It will set the atime, mtime, or both to 0. For UTIME_NOW (in both) we'd simply pass NULL to utimes(2). For UTIME_OMIT (in both) we'd simply skip the call to utimes(2) altogether. The harder part is a mixed mode (i.e. the truncate fix mentioned in the above commit). I think the only way to handle UTIME_NOW in one is to call gettimeofday (or clock_gettime for better resolution) to find out what current time is. And for UTIME_OMIT call stat to find out what the current setting is and reset to that value. Both of those cases can possibly zero out the extra precision (providing only seconds resolution). thanks, -chris