From b98f732ce74d7ae47e2fc0373f850cec1a8c2ce8 Mon Sep 17 00:00:00 2001 From: jilles Date: Tue, 17 Feb 2015 13:12:54 +0000 Subject: compress,gzip,xz: Preserve timestamps with nanosecond precision. --- usr.bin/compress/compress.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'usr.bin/compress') diff --git a/usr.bin/compress/compress.c b/usr.bin/compress/compress.c index 1f458e5..2d2efb3 100644 --- a/usr.bin/compress/compress.c +++ b/usr.bin/compress/compress.c @@ -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 -- cgit v1.1