Commit 489a1c39 authored by Adam Borowski's avatar Adam Borowski Committed by Kevin J. McCarthy

manually touch atime when reading a mbox file

The only common use of atime left is local mail agents leaving a mark on
mbox file after the mail has been read.  And, since POSIX-2008, it is
possible to use futimens() to alter atime even on filesystems mounted with
noatime.

There's no extra cost for doing this on when atime updates are enabled:
the inode will be dirty already.
parent f030bd36
......@@ -448,6 +448,9 @@ AC_CHECK_FUNCS(ftruncate, , [AC_CHECK_LIB(x, chsize)])
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])
......
......@@ -392,6 +392,12 @@ static void show_version (void)
#else
"-HAVE_RESIZETERM "
#endif
#ifdef HAVE_FUTIMENS
"+HAVE_FUTIMENS "
#else
"-HAVE_FUTIMENS "
#endif
);
puts (
......
......@@ -436,6 +436,7 @@ static int mbox_open_mailbox (CONTEXT *ctx)
rc = mmdf_parse_mailbox (ctx);
else
rc = -1;
mutt_touch_atime (fileno (ctx->fp));
mbox_unlock_mailbox (ctx);
mutt_unblock_signals ();
......@@ -1257,6 +1258,8 @@ int mutt_reopen_mailbox (CONTEXT *ctx, int *index_hint)
return (-1);
}
mutt_touch_atime (fileno (ctx->fp));
/* now try to recover the old flags */
index_hint_set = (index_hint == NULL);
......
......@@ -1942,6 +1942,16 @@ void mutt_set_mtime (const char* from, const char* to)
}
}
/* 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];
......
......@@ -122,6 +122,7 @@ time_t mutt_local_tz (time_t);
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,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment