From bc2fc3a981e9f1e81a864da903f71bc8885ed881 Mon Sep 17 00:00:00 2001 From: Philip Guenther Date: Sun, 3 May 2015 19:45:00 +0000 Subject: Preserve times to nanosecond precision instead of just microsecond. Prefer to set attributes by fd for regular files, and not follwing symlinks for others. ok brynet@ millert@ --- usr.bin/compress/main.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'usr.bin/compress') diff --git a/usr.bin/compress/main.c b/usr.bin/compress/main.c index c9e302598ff..4d91398b9a3 100644 --- a/usr.bin/compress/main.c +++ b/usr.bin/compress/main.c @@ -1,4 +1,4 @@ -/* $OpenBSD: main.c,v 1.83 2015/01/16 06:40:06 deraadt Exp $ */ +/* $OpenBSD: main.c,v 1.84 2015/05/03 19:44:59 guenther Exp $ */ /* * Copyright (c) 1992, 1993 @@ -750,7 +750,7 @@ dodecompress(const char *in, char *out, const struct compressor *method, void setfile(const char *name, int fd, struct stat *fs) { - struct timeval tv[2]; + struct timespec ts[2]; if (name == NULL || cat || testmode) return; @@ -784,10 +784,10 @@ setfile(const char *name, int fd, struct stat *fs) if (fs->st_flags && fchflags(fd, fs->st_flags)) warn("fchflags: %s", name); - TIMESPEC_TO_TIMEVAL(&tv[0], &fs->st_atimespec); - TIMESPEC_TO_TIMEVAL(&tv[1], &fs->st_mtimespec); - if (futimes(fd, tv)) - warn("futimes: %s", name); + ts[0] = fs->st_atim; + ts[1] = fs->st_mtim; + if (futimens(fd, ts)) + warn("futimens: %s", name); } int -- cgit v1.2.3