From: guenther Date: Tue, 13 Oct 2015 08:49:51 +0000 (+0000) Subject: To alter just the atime of the mailspool, use utimensat()+UTIME_OMIT instead X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=77fba80380b06808f4f4034f83899ffb0fe9f6c5;p=openbsd 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@ --- 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 #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 -#include #include #include