futimens is a new thing, coming from POSIX-2008, yet all modern Unices added
it almost immediately. If it isn't implemented, silently ignoring that is
no worse than current state.
While performance issues related to atime updates have been greatly reduced
by relatime and lazytime, it is an abomination for other reasons: CoW
filesystems (btrfs, zfs, ...), CoWed VM images, deduplicating thin
provisioning, etc lose significant space for every snapshot. It also causes
wear on flash-based storage prevalent on SoCs, and so on. Thus, it is
prudent to mount everything with noatime.
There is only one real use for atime these days: new mail notification on
mbox files. With only a limited number of readers (mutt is one), let's
do atime updates manually.
This can be done unconditionally: while redundant without noatime, there's
no performance loss as the inode will be dirty already in such case.
Closes: #272
dnl SCO has strftime() in libintl
AC_CHECK_FUNCS(strftime, , [AC_CHECK_LIB(intl, strftime)])
+dnl Set the atime of files
+AC_CHECK_FUNCS(futimens)
+
dnl AIX may not have fchdir()
AC_CHECK_FUNCS(fchdir, , [mutt_cv_fchdir=no])
rc = mmdf_parse_mailbox (ctx);
else
rc = -1;
+ mutt_touch_atime (fileno (ctx->fp));
mbox_unlock_mailbox (ctx);
mutt_unblock_signals ();
return (-1);
}
+ mutt_touch_atime (fileno (ctx->fp));
+
/* now try to recover the old flags */
index_hint_set = (index_hint == NULL);
}
}
+/* set atime to current time, just as read() would do on !noatime.
+ * Silently ignored if unsupported. */
+void mutt_touch_atime (int f)
+{
+#ifdef HAVE_FUTIMENS
+ struct timespec times[2]={{0,UTIME_NOW},{0,UTIME_OMIT}};
+ futimens(f, times);
+#endif
+}
+
const char *mutt_make_version (void)
{
static char vstring[STRING];
time_t mutt_mktime (struct tm *, int);
time_t mutt_parse_date (const char *, HEADER *);
int is_from (const char *, char *, size_t, time_t *);
+void mutt_touch_atime (int);
const char *mutt_attach_fmt (
char *dest,
#else
{ "HAVE_CURS_SET", 0 },
#endif
+#ifdef HAVE_FUTIMENS
+ { "HAVE_FUTIMENS", 1 },
+#else
+ { "HAVE_FUTIMENS", 0 },
+#endif
#ifdef HAVE_GETADDRINFO
{ "HAVE_GETADDRINFO", 1 },
#else