From owner-svn-src-all@FreeBSD.ORG Sun Mar 15 21:29:21 2015 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id DB1B06D1; Sun, 15 Mar 2015 21:29:21 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id ADA7A9F7; Sun, 15 Mar 2015 21:29:21 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id t2FLTLZF091453; Sun, 15 Mar 2015 21:29:21 GMT (envelope-from jilles@FreeBSD.org) Received: (from jilles@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id t2FLTLhI091452; Sun, 15 Mar 2015 21:29:21 GMT (envelope-from jilles@FreeBSD.org) Message-Id: <201503152129.t2FLTLhI091452@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: jilles set sender to jilles@FreeBSD.org using -f From: Jilles Tjoelker Date: Sun, 15 Mar 2015 21:29:21 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r280117 - head/usr.bin/unzip X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 15 Mar 2015 21:29:22 -0000 Author: jilles Date: Sun Mar 15 21:29:20 2015 New Revision: 280117 URL: https://svnweb.freebsd.org/changeset/base/280117 Log: unzip: Don't subvert vfs.timestamp_precision when setting atime to now. Also, preserve nanoseconds from libarchive, even though the zip file format does not currently support nanoseconds in timestamps. Modified: head/usr.bin/unzip/unzip.c Modified: head/usr.bin/unzip/unzip.c ============================================================================== --- head/usr.bin/unzip/unzip.c Sun Mar 15 21:29:18 2015 (r280116) +++ head/usr.bin/unzip/unzip.c Sun Mar 15 21:29:20 2015 (r280117) @@ -67,9 +67,6 @@ static int u_opt; /* update */ static int v_opt; /* verbose/list */ static int Z1_opt; /* zipinfo mode list files only */ -/* time when unzip started */ -static time_t now; - /* debug flag */ static int unzip_debug; @@ -470,9 +467,9 @@ static void extract_file(struct archive *a, struct archive_entry *e, char **path) { int mode; - time_t mtime; + struct timespec mtime; struct stat sb; - struct timeval tv[2]; + struct timespec ts[2]; int cr, fd, text, warn, check; ssize_t len; unsigned char *p, *q, *end; @@ -480,14 +477,18 @@ extract_file(struct archive *a, struct a mode = archive_entry_mode(e) & 0777; if (mode == 0) mode = 0644; - mtime = archive_entry_mtime(e); + mtime.tv_sec = archive_entry_mtime(e); + mtime.tv_nsec = archive_entry_mtime_nsec(e); /* look for existing file of same name */ recheck: if (lstat(*path, &sb) == 0) { if (u_opt || f_opt) { /* check if up-to-date */ - if (S_ISREG(sb.st_mode) && sb.st_mtime >= mtime) + if (S_ISREG(sb.st_mode) && + (sb.st_mtim.tv_sec > mtime.tv_sec || + (sb.st_mtim.tv_sec == mtime.tv_sec && + sb.st_mtim.tv_nsec >= mtime.tv_nsec))) return; (void)unlink(*path); } else if (o_opt) { @@ -593,12 +594,11 @@ recheck: info("\n"); /* set access and modification time */ - tv[0].tv_sec = now; - tv[0].tv_usec = 0; - tv[1].tv_sec = mtime; - tv[1].tv_usec = 0; - if (futimes(fd, tv) != 0) - error("utimes('%s')", *path); + ts[0].tv_sec = 0; + ts[0].tv_nsec = UTIME_NOW; + ts[1] = mtime; + if (futimens(fd, ts) != 0) + error("futimens('%s')", *path); if (close(fd) != 0) error("close('%s')", *path); } @@ -1065,8 +1065,6 @@ main(int argc, char *argv[]) if (n_opt + o_opt + u_opt > 1) errorx("-n, -o and -u are contradictory"); - time(&now); - unzip(zipfile); exit(0);