|
| 1 | +diff --git src/ls.c src/ls.c |
| 2 | +index 24b983287..4acf5f44d 100644 |
| 3 | +--- src/ls.c |
| 4 | ++++ src/ls.c |
| 5 | +@@ -49,10 +49,6 @@ |
| 6 | + # include <sys/ptem.h> |
| 7 | + #endif |
| 8 | + |
| 9 | +-#ifdef __linux__ |
| 10 | +-# include <sys/syscall.h> |
| 11 | +-#endif |
| 12 | +- |
| 13 | + #include <stdio.h> |
| 14 | + #include <assert.h> |
| 15 | + #include <setjmp.h> |
| 16 | +@@ -2896,7 +2892,6 @@ print_dir (char const *name, char const *realname, bool command_line_arg) |
| 17 | + struct dirent *next; |
| 18 | + uintmax_t total_blocks = 0; |
| 19 | + static bool first = true; |
| 20 | +- bool found_any_entries = false; |
| 21 | + |
| 22 | + errno = 0; |
| 23 | + dirp = opendir (name); |
| 24 | +@@ -2972,7 +2967,6 @@ print_dir (char const *name, char const *realname, bool command_line_arg) |
| 25 | + next = readdir (dirp); |
| 26 | + if (next) |
| 27 | + { |
| 28 | +- found_any_entries = true; |
| 29 | + if (! file_ignored (next->d_name)) |
| 30 | + { |
| 31 | + enum filetype type = unknown; |
| 32 | +@@ -3018,22 +3012,6 @@ print_dir (char const *name, char const *realname, bool command_line_arg) |
| 33 | + if (errno != EOVERFLOW) |
| 34 | + break; |
| 35 | + } |
| 36 | +-#ifdef __linux__ |
| 37 | +- else if (! found_any_entries) |
| 38 | +- { |
| 39 | +- /* If readdir finds no directory entries at all, not even "." or |
| 40 | +- "..", then double check that the directory exists. */ |
| 41 | +- if (syscall (SYS_getdents, dirfd (dirp), NULL, 0) == -1 |
| 42 | +- && errno != EINVAL) |
| 43 | +- { |
| 44 | +- /* We exclude EINVAL as that pertains to buffer handling, |
| 45 | +- and we've passed NULL as the buffer for simplicity. |
| 46 | +- ENOENT is returned if appropriate before buffer handling. */ |
| 47 | +- file_failure (command_line_arg, _("reading directory %s"), name); |
| 48 | +- } |
| 49 | +- break; |
| 50 | +- } |
| 51 | +-#endif |
| 52 | + else |
| 53 | + break; |
| 54 | + |
| 55 | +diff --git tests/ls/removed-directory.sh tests/ls/removed-directory.sh |
| 56 | +index e8c835dab..fe8f929a1 100755 |
| 57 | +--- tests/ls/removed-directory.sh |
| 58 | ++++ tests/ls/removed-directory.sh |
| 59 | +@@ -26,20 +26,14 @@ case $host_triplet in |
| 60 | + *) skip_ 'non linux kernel' ;; |
| 61 | + esac |
| 62 | + |
| 63 | +-LS_FAILURE=2 |
| 64 | +- |
| 65 | +-cat <<\EOF >exp-err || framework_failure_ |
| 66 | +-ls: reading directory '.': No such file or directory |
| 67 | +-EOF |
| 68 | +- |
| 69 | + cwd=$(pwd) |
| 70 | + mkdir d || framework_failure_ |
| 71 | + cd d || framework_failure_ |
| 72 | + rmdir ../d || framework_failure_ |
| 73 | + |
| 74 | +-returns_ $LS_FAILURE ls >../out 2>../err || fail=1 |
| 75 | ++ls >../out 2>../err || fail=1 |
| 76 | + cd "$cwd" || framework_failure_ |
| 77 | + compare /dev/null out || fail=1 |
| 78 | +-compare exp-err err || fail=1 |
| 79 | ++compare /dev/null err || fail=1 |
| 80 | + |
| 81 | + Exit $fail |
| 82 | +-- |
| 83 | +2.24.0.375.geb5ae68d41 |
| 84 | + |
0 commit comments