summaryrefslogtreecommitdiffstats
path: root/bin/mv
diff options
context:
space:
mode:
authorjilles <jilles@FreeBSD.org>2015-01-24 13:50:13 +0000
committerjilles <jilles@FreeBSD.org>2015-01-24 13:50:13 +0000
commit3a9e3cd8d9759079220ebe0f13a1d1a8a458734e (patch)
tree2b470ac738f4b696f867cd706f33163b46c962c6 /bin/mv
parentb126e557b253b006789504806612c8f6dc907bbe (diff)
downloadFreeBSD-src-3a9e3cd8d9759079220ebe0f13a1d1a8a458734e.zip
FreeBSD-src-3a9e3cd8d9759079220ebe0f13a1d1a8a458734e.tar.gz
cp,mv,touch: Set timestamps with nanosecond precision.
This uses utimensat().
Diffstat (limited to 'bin/mv')
-rw-r--r--bin/mv/mv.c9
1 files changed, 4 insertions, 5 deletions
diff --git a/bin/mv/mv.c b/bin/mv/mv.c
index 3e832ac..999c8fc 100644
--- a/bin/mv/mv.c
+++ b/bin/mv/mv.c
@@ -273,7 +273,7 @@ do_move(const char *from, const char *to)
static int
fastcopy(const char *from, const char *to, struct stat *sbp)
{
- struct timeval tval[2];
+ struct timespec ts[2];
static u_int blen = MAXPHYS;
static char *bp = NULL;
mode_t oldmode;
@@ -350,10 +350,9 @@ err: if (unlink(to))
} else
warn("%s: cannot stat", to);
- tval[0].tv_sec = sbp->st_atime;
- tval[1].tv_sec = sbp->st_mtime;
- tval[0].tv_usec = tval[1].tv_usec = 0;
- if (utimes(to, tval))
+ ts[0] = sbp->st_atim;
+ ts[1] = sbp->st_mtim;
+ if (utimensat(AT_FDCWD, to, ts, 0))
warn("%s: set times", to);
if (close(to_fd)) {
OpenPOWER on IntegriCloud