diff options
author | Jasper Lievisse Adriaanse <jasper@cvs.openbsd.org> | 2016-01-26 18:02:52 +0000 |
---|---|---|
committer | Jasper Lievisse Adriaanse <jasper@cvs.openbsd.org> | 2016-01-26 18:02:52 +0000 |
commit | d11e25ef62dfb6b4f7c303711ec62676b5d0a75b (patch) | |
tree | 326e9d78929b1edd0ff788f92deeadf2e34ab300 | |
parent | 4f84334ce817622f41049363b4f0b6b0c0cdea8c (diff) |
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.c | 9 |
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) { |