summaryrefslogtreecommitdiff
path: root/usr.bin
diff options
context:
space:
mode:
authorPhilip Guenther <guenther@cvs.openbsd.org>2015-10-13 08:49:52 +0000
committerPhilip Guenther <guenther@cvs.openbsd.org>2015-10-13 08:49:52 +0000
commitd69ae064a4a6cc0082c84febcbacab5aa45dfe78 (patch)
tree990a62d616e09ad5a7e1c68aad262d7e1217c228 /usr.bin
parente77a985abf71bfcf96f77c16a0942a28ecfba751 (diff)
To alter just the atime of the mailspool, use utimensat()+UTIME_OMIT instead
of stat()+utimes(). Prefer clock_gettime() over gettimeofday() to avoid timeval->timespec conversion ok millert@
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/mail/aux.c22
-rw-r--r--usr.bin/mail/def.h5
2 files changed, 10 insertions, 17 deletions
diff --git a/usr.bin/mail/aux.c b/usr.bin/mail/aux.c
index 31a6d9b7643..a6987a1eb2e 100644
--- a/usr.bin/mail/aux.c
+++ b/usr.bin/mail/aux.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: aux.c,v 1.27 2015/01/16 06:40:09 deraadt Exp $ */
+/* $OpenBSD: aux.c,v 1.28 2015/10/13 08:49:51 guenther Exp $ */
/* $NetBSD: aux.c,v 1.5 1997/05/13 06:15:52 mikel Exp $ */
/*
@@ -31,6 +31,7 @@
*/
#include "rcv.h"
+#include <fcntl.h>
#include "extern.h"
/*
@@ -328,19 +329,12 @@ unstack(void)
void
alter(char *name)
{
- struct stat sb;
- struct timeval tv[2];
-
- if (stat(name, &sb))
- return;
- (void) gettimeofday(&tv[0], (struct timezone *)0);
- tv[0].tv_sec++;
-#ifdef TIMESPEC_TO_TIMEVAL
- TIMESPEC_TO_TIMEVAL(&tv[1], &sb.st_mtimespec);
-#else
- tv[1].tv_sec = sb.st_mtime;
-#endif
- (void)utimes(name, tv);
+ struct timespec ts[2];
+
+ clock_gettime(CLOCK_REALTIME, &ts[0]);
+ ts[0].tv_sec++;
+ ts[1].tv_nsec = UTIME_OMIT;
+ (void)utimensat(AT_FDCWD, name, ts, 0);
}
/*
diff --git a/usr.bin/mail/def.h b/usr.bin/mail/def.h
index a1f1a9675f8..3a26cc7e860 100644
--- a/usr.bin/mail/def.h
+++ b/usr.bin/mail/def.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: def.h,v 1.15 2015/01/20 16:59:07 millert Exp $ */
+/* $OpenBSD: def.h,v 1.16 2015/10/13 08:49:51 guenther Exp $ */
/* $NetBSD: def.h,v 1.9 1996/12/28 07:11:00 tls Exp $ */
/*
@@ -30,7 +30,7 @@
* SUCH DAMAGE.
*
* @(#)def.h 8.4 (Berkeley) 4/20/95
- * $OpenBSD: def.h,v 1.15 2015/01/20 16:59:07 millert Exp $
+ * $OpenBSD: def.h,v 1.16 2015/10/13 08:49:51 guenther Exp $
*/
/*
@@ -43,7 +43,6 @@
#define MAIL_DEF_H
#include <sys/stat.h>
-#include <sys/time.h>
#include <ctype.h>
#include <err.h>