diff options
author | Theo de Raadt <deraadt@cvs.openbsd.org> | 2019-02-16 05:30:29 +0000 |
---|---|---|
committer | Theo de Raadt <deraadt@cvs.openbsd.org> | 2019-02-16 05:30:29 +0000 |
commit | 0444afa8cff9f9055419f0364fa0992f9081bc28 (patch) | |
tree | e6a279c467288ee4cbf92282f876555d1ef545fa /usr.bin | |
parent | 0e880eaeb28930555ea39c62ed0a9b3ddba5dc21 (diff) |
use gettimeofday + TIMEVAL_TO_TIMESPEC to create timespec with better
than 1 sec resolution
ok benno
Diffstat (limited to 'usr.bin')
-rw-r--r-- | usr.bin/rsync/receiver.c | 8 | ||||
-rw-r--r-- | usr.bin/rsync/uploader.c | 8 |
2 files changed, 10 insertions, 6 deletions
diff --git a/usr.bin/rsync/receiver.c b/usr.bin/rsync/receiver.c index 2a33eb1fbf1..935432beb58 100644 --- a/usr.bin/rsync/receiver.c +++ b/usr.bin/rsync/receiver.c @@ -1,4 +1,4 @@ -/* $Id: receiver.c,v 1.10 2019/02/16 05:25:09 deraadt Exp $ */ +/* $Id: receiver.c,v 1.11 2019/02/16 05:30:28 deraadt Exp $ */ /* * Copyright (c) 2019 Kristaps Dzonsons <kristaps@bsd.lv> @@ -75,8 +75,10 @@ rsync_set_metadata(struct sess *sess, int newfile, /* Conditionally adjust file modification time. */ if (sess->opts->preserve_times) { - tv[0].tv_sec = time(NULL); - tv[0].tv_nsec = 0; + struct timeval now; + + gettimeofday(&now, NULL); + TIMEVAL_TO_TIMESPEC(&now, &tv[0]); tv[1].tv_sec = f->st.mtime; tv[1].tv_nsec = 0; if (futimens(fd, tv) == -1) { diff --git a/usr.bin/rsync/uploader.c b/usr.bin/rsync/uploader.c index 81c6fd88f64..7f2d52e3c17 100644 --- a/usr.bin/rsync/uploader.c +++ b/usr.bin/rsync/uploader.c @@ -1,4 +1,4 @@ -/* $Id: uploader.c,v 1.7 2019/02/16 05:06:30 deraadt Exp $ */ +/* $Id: uploader.c,v 1.8 2019/02/16 05:30:28 deraadt Exp $ */ /* * Copyright (c) 2019 Kristaps Dzonsons <kristaps@bsd.lv> * @@ -242,8 +242,10 @@ pre_link(struct upload *p, struct sess *sess) */ if (sess->opts->preserve_times) { - tv[0].tv_sec = time(NULL); - tv[0].tv_nsec = 0; + struct timeval now; + + gettimeofday(&now, NULL); + TIMEVAL_TO_TIMESPEC(&now, &tv[0]); tv[1].tv_sec = f->st.mtime; tv[1].tv_nsec = 0; rc = utimensat(p->rootfd, f->path, tv, AT_SYMLINK_NOFOLLOW); |