From owner-svn-src-all@FreeBSD.ORG Tue Feb 17 13:12:55 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 D5C83DC4; Tue, 17 Feb 2015 13:12:55 +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 A8A9919A; Tue, 17 Feb 2015 13:12:55 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id t1HDCt5u009194; Tue, 17 Feb 2015 13:12:55 GMT (envelope-from jilles@FreeBSD.org) Received: (from jilles@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id t1HDCsmM009191; Tue, 17 Feb 2015 13:12:54 GMT (envelope-from jilles@FreeBSD.org) Message-Id: <201502171312.t1HDCsmM009191@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: jilles set sender to jilles@FreeBSD.org using -f From: Jilles Tjoelker Date: Tue, 17 Feb 2015 13:12:54 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r278896 - in head: lib/liblzma usr.bin/compress usr.bin/gzip 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: Tue, 17 Feb 2015 13:12:55 -0000 Author: jilles Date: Tue Feb 17 13:12:54 2015 New Revision: 278896 URL: https://svnweb.freebsd.org/changeset/base/278896 Log: compress,gzip,xz: Preserve timestamps with nanosecond precision. Modified: head/lib/liblzma/config.h head/usr.bin/compress/compress.c head/usr.bin/gzip/gzip.c Modified: head/lib/liblzma/config.h ============================================================================== --- head/lib/liblzma/config.h Tue Feb 17 13:09:20 2015 (r278895) +++ head/lib/liblzma/config.h Tue Feb 17 13:12:54 2015 (r278896) @@ -26,6 +26,7 @@ #define HAVE_ENCODER_SPARC 1 #define HAVE_ENCODER_X86 1 #define HAVE_FCNTL_H 1 +#define HAVE_FUTIMENS 1 #define HAVE_FUTIMES 1 #define HAVE_GETOPT_H 1 #define HAVE_GETOPT_LONG 1 Modified: head/usr.bin/compress/compress.c ============================================================================== --- head/usr.bin/compress/compress.c Tue Feb 17 13:09:20 2015 (r278895) +++ head/usr.bin/compress/compress.c Tue Feb 17 13:12:54 2015 (r278896) @@ -48,6 +48,7 @@ __FBSDID("$FreeBSD$"); #include #include +#include #include #include #include @@ -360,14 +361,14 @@ err: if (ofp) { static void setfile(const char *name, struct stat *fs) { - static struct timeval tv[2]; + static struct timespec tspec[2]; fs->st_mode &= S_ISUID|S_ISGID|S_IRWXU|S_IRWXG|S_IRWXO; - TIMESPEC_TO_TIMEVAL(&tv[0], &fs->st_atim); - TIMESPEC_TO_TIMEVAL(&tv[1], &fs->st_mtim); - if (utimes(name, tv)) - cwarn("utimes: %s", name); + tspec[0] = fs->st_atim; + tspec[1] = fs->st_mtim; + if (utimensat(AT_FDCWD, name, tspec, 0)) + cwarn("utimensat: %s", name); /* * Changing the ownership probably won't succeed, unless we're root Modified: head/usr.bin/gzip/gzip.c ============================================================================== --- head/usr.bin/gzip/gzip.c Tue Feb 17 13:09:20 2015 (r278895) +++ head/usr.bin/gzip/gzip.c Tue Feb 17 13:12:54 2015 (r278896) @@ -1070,7 +1070,7 @@ out2: static void copymodes(int fd, const struct stat *sbp, const char *file) { - struct timeval times[2]; + struct timespec times[2]; struct stat sb; /* @@ -1098,10 +1098,10 @@ copymodes(int fd, const struct stat *sbp if (fchmod(fd, sb.st_mode) < 0) maybe_warn("couldn't fchmod: %s", file); - TIMESPEC_TO_TIMEVAL(×[0], &sb.st_atim); - TIMESPEC_TO_TIMEVAL(×[1], &sb.st_mtim); - if (futimes(fd, times) < 0) - maybe_warn("couldn't utimes: %s", file); + times[0] = sb.st_atim; + times[1] = sb.st_mtim; + if (futimens(fd, times) < 0) + maybe_warn("couldn't futimens: %s", file); /* only try flags if they exist already */ if (sb.st_flags != 0 && fchflags(fd, sb.st_flags) < 0)