From b1bc3c1c6e97fc53fa813575611d84a0295d5e5d Mon Sep 17 00:00:00 2001 From: Bernhard Voelker Date: Sat, 29 Sep 2018 11:17:13 +0200 Subject: [PATCH] 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. * lib/fts_.h (FTS_NOATIME): Remove bit flag. (FTS_OPTIONMASK): Adjust. * lib/fts.c (diropen, fts_open, fts_build): Likewise. (fd_ring_check): Likewise. --- ChangeLog | 13 +++++++++++++ lib/fts.c | 11 ++++------- lib/fts_.h | 2 +- 3 files changed, 18 insertions(+), 8 deletions(-) diff --git a/ChangeLog b/ChangeLog index 03aab337a..bf06f4318 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,16 @@ +2018-09-29 Bernhard Voelker + + 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. + * 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-09-27 Akim Demaille timevar: import from Bison. diff --git a/lib/fts.c b/lib/fts.c index 1ccc78c11..aaa6bb293 100644 --- a/lib/fts.c +++ b/lib/fts.c @@ -370,8 +370,7 @@ internal_function 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 @@ fts_open (char * const *argv, 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 @@ set_stat_type (struct stat *st, unsigned int dtype) (((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 @@ fd_ring_check (FTS const *sp) 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) { diff --git a/lib/fts_.h b/lib/fts_.h index 70cc9e3d6..6188122fd 100644 --- a/lib/fts_.h +++ b/lib/fts_.h @@ -149,7 +149,7 @@ typedef struct { 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. */ -- 2.19.0