svn commit: r278896 - in head: lib/liblzma usr.bin/compress usr.bin/gzip
Jilles Tjoelker
jilles at FreeBSD.org
Tue Feb 17 13:12:55 UTC 2015
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 <err.h>
#include <errno.h>
+#include <fcntl.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
@@ -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)
More information about the svn-src-head
mailing list