summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjasper <jasper@openbsd.org>2016-01-26 18:02:51 +0000
committerjasper <jasper@openbsd.org>2016-01-26 18:02:51 +0000
commit16b24e905234719123ce75eec8b105176d2ca62d (patch)
tree40dc45fe52553fcfa6e775f18358020301638360
parentremove a useless macro (diff)
downloadwireguard-openbsd-16b24e905234719123ce75eec8b105176d2ca62d.tar.xz
wireguard-openbsd-16b24e905234719123ce75eec8b105176d2ca62d.zip
ensure the backup file has the same mtime as the original file, this is in line
with emacs' behaviour. from Harald Dunkel via Han Boetes ok lum@
-rw-r--r--usr.bin/mg/fileio.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/usr.bin/mg/fileio.c b/usr.bin/mg/fileio.c
index bc392dc3006..0c5a9e28ce6 100644
--- a/usr.bin/mg/fileio.c
+++ b/usr.bin/mg/fileio.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: fileio.c,v 1.99 2015/03/19 21:22:15 bcallah Exp $ */
+/* $OpenBSD: fileio.c,v 1.100 2016/01/26 18:02:51 jasper Exp $ */
/* This file is in the public domain. */
@@ -266,6 +266,13 @@ fbackupfile(const char *fn)
}
serrno = errno;
(void) fchmod(to, (sb.st_mode & 0777));
+
+ /* copy the mtime to the backupfile */
+ struct timespec new_times[2];
+ new_times[0] = sb.st_atim;
+ new_times[1] = sb.st_mtim;
+ futimens(to, new_times);
+
close(from);
close(to);
if (nread == -1) {