changeset 39901:33cf8a9f314a

fts: remove FTS_NOATIME This reverts commit da4d6974013c822af1498941e32db774b2031765. We cannot guarantee that O_NOATIME works: e.g. openat fails with EPERM if the effective user ID of the caller does not match the owner of the file and the caller is not privileged. Downstream findutils has never picked up FTS_NOATIME. Discussed at <https://lists.gnu.org/r/bug-gnulib/2018-09/msg00122.html>. * lib/fts_.h (FTS_NOATIME): Remove bit flag. (FTS_OPTIONMASK): Adjust. * lib/fts.c (diropen, fts_open, fts_build): Likewise. (fd_ring_check): Likewise.
author Bernhard Voelker <mail@bernhard-voelker.de>
date Mon, 08 Oct 2018 16:45:36 -0700
parents c90f29b80ee8
children 74aa8d21daa5
files ChangeLog lib/fts.c lib/fts_.h
diffstat 3 files changed, 19 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Tue Oct 09 01:44:07 2018 +0200
+++ b/ChangeLog	Mon Oct 08 16:45:36 2018 -0700
@@ -1,3 +1,17 @@
+2018-10-08  Bernhard Voelker  <mail@bernhard-voelker.de>
+
+	fts: remove FTS_NOATIME
+	This reverts commit da4d6974013c822af1498941e32db774b2031765.
+	We cannot guarantee that O_NOATIME works: e.g. openat fails
+	with EPERM if the effective user ID of the caller does not match
+	the owner of the file and the caller is not privileged.
+	Downstream findutils has never picked up FTS_NOATIME.  Discussed at
+	<https://lists.gnu.org/r/bug-gnulib/2018-09/msg00122.html>.
+	* lib/fts_.h (FTS_NOATIME): Remove bit flag.
+	(FTS_OPTIONMASK): Adjust.
+	* lib/fts.c (diropen, fts_open, fts_build): Likewise.
+	(fd_ring_check): Likewise.
+
 2018-10-08  Bruno Haible  <bruno@clisp.org>
 
 	csharpcomp*, csharpexec*: Remove support for pnet.
--- a/lib/fts.c	Tue Oct 09 01:44:07 2018 +0200
+++ b/lib/fts.c	Mon Oct 08 16:45:36 2018 -0700
@@ -370,8 +370,7 @@
 diropen (FTS const *sp, char const *dir)
 {
   int open_flags = (O_SEARCH | O_CLOEXEC | O_DIRECTORY | O_NOCTTY | O_NONBLOCK
-                    | (ISSET (FTS_PHYSICAL) ? O_NOFOLLOW : 0)
-                    | (ISSET (FTS_NOATIME) ? O_NOATIME : 0));
+                    | (ISSET (FTS_PHYSICAL) ? O_NOFOLLOW : 0));
 
   int fd = (ISSET (FTS_CWDFD)
             ? openat (sp->fts_cwd_fd, dir, open_flags)
@@ -426,8 +425,7 @@
                early, doing it here saves us the trouble of ensuring
                later (where it'd be messier) that "." can in fact
                be opened.  If not, revert to FTS_NOCHDIR mode.  */
-            int fd = open (".",
-                           O_SEARCH | (ISSET (FTS_NOATIME) ? O_NOATIME : 0));
+            int fd = open (".", O_SEARCH);
             if (fd < 0)
               {
                 /* Even if "." is unreadable, don't revert to FTS_NOCHDIR mode
@@ -1304,8 +1302,7 @@
                   (((ISSET(FTS_PHYSICAL)                        \
                      && ! (ISSET(FTS_COMFOLLOW)                 \
                            && cur->fts_level == FTS_ROOTLEVEL)) \
-                    ? O_NOFOLLOW : 0)                           \
-                   | (ISSET (FTS_NOATIME) ? O_NOATIME : 0)),    \
+                    ? O_NOFOLLOW : 0)),                         \
                   Pdir_fd)
 
 /*
@@ -1796,7 +1793,7 @@
       int fd = i_ring_pop (&fd_w);
       if (0 <= fd)
         {
-          int open_flags = O_SEARCH | O_CLOEXEC | O_NOATIME;
+          int open_flags = O_SEARCH | O_CLOEXEC;
           int parent_fd = openat (cwd_fd, "..", open_flags);
           if (parent_fd < 0)
             {
--- a/lib/fts_.h	Tue Oct 09 01:44:07 2018 +0200
+++ b/lib/fts_.h	Mon Oct 08 16:45:36 2018 -0700
@@ -149,7 +149,7 @@
      dirent.d_type data.  */
 # define FTS_DEFER_STAT         0x0400
 
-# define FTS_NOATIME    0x0800          /* use O_NOATIME during traversal */
+/* 0x0800 unused, was non-working FTS_NOATIME */
 
   /* Use this flag to disable stripping of trailing slashes
      from input path names during fts_open initialization.  */