find: process unreadable directories with -depth

* find/ftsfind.c (consider_visiting): Split the FTS_ERR and FTS_DNR
cases to be able to continue processing that entry in the latter case
(unreadable directory) when the -depth option is given.
* NEWS (Bug Fixes): Mention the fix.

Reported by Tavian Barnes in https://savannah.gnu.org/bugs/?54171.
This commit is contained in:
2018-07-08 00:17:27 +02:00
parent bb51d3581d
commit 22ff99e150
2 changed files with 17 additions and 2 deletions

4
NEWS
View File

@@ -54,6 +54,10 @@ Some minor documentation improvements are listed in "Bug Fixes" below.
** Bug Fixes
#54171: 'find -depth' now outputs the name of unreadable directories.
Previously, FTS-based find missed to output those entries.
Bug present since the FTS implementation in FINDUTILS_4_3_0-1.
#52981: find: the '-delete' action no longer complains about disappeared files
when the '-ignore_readdir_race' option is given, too. That action will
also returns true in such a case now.

View File

@@ -342,12 +342,23 @@ consider_visiting (FTS *p, FTSENT *ent)
statbuf.st_ino = ent->fts_statp->st_ino;
/* Cope with various error conditions. */
if (ent->fts_info == FTS_ERR
|| ent->fts_info == FTS_DNR)
if (ent->fts_info == FTS_ERR)
{
nonfatal_target_file_error (ent->fts_errno, ent->fts_path);
return;
}
if (ent->fts_info == FTS_DNR)
{
nonfatal_target_file_error (ent->fts_errno, ent->fts_path);
if (options.do_dir_first)
{
/* Return for unreadable directories without -depth.
* With -depth, the directory itself has to be processed, yet the
* error message above has to be output.
*/
return;
}
}
else if (ent->fts_info == FTS_DC)
{
issue_loop_warning (ent);