Index: usr.bin/find/find.c =================================================================== --- usr.bin/find/find.c +++ usr.bin/find/find.c @@ -207,6 +207,9 @@ warnx("%s: %s", entry->fts_path, strerror(entry->fts_errno)); exitstatus = 1; + if (entry->fts_info == FTS_DNR && isdepth) { + break; + } continue; #if defined(FTS_W) && defined(FTS_WHITEOUT) case FTS_W: Index: usr.bin/find/tests/find_test.sh =================================================================== --- usr.bin/find/tests/find_test.sh +++ usr.bin/find/tests/find_test.sh @@ -65,8 +65,26 @@ atf_check -s exit:0 -o "inline:test/link2\n" find test -samefile test/link2 } +atf_test_case find_depth_error +find_depth_error_head() +{ + atf_set "descr" "Verifies that unreadable directories are still " \ + "reported in -depth mode" + atf_set "require.user" "unprivileged" +} +find_depth_error_body() +{ + atf_check -s exit:0 mkdir -p test/dir + atf_check -s exit:0 chmod -r test/dir + + # find(1) should still print unreadable directories when invoked with + # -depth + atf_check -s exit:1 -o "inline:test/dir\ntest\n" -e ignore find test -depth +} + atf_init_test_cases() { atf_add_test_case find_newer_link atf_add_test_case find_samefile_link + atf_add_test_case find_depth_error }