1 From 10fcb97bd728f09d4a027eddf8ad2900f0819b0a Mon Sep 17 00:00:00 2001
2 From: Paul Eggert <eggert@cs.ucla.edu>
3 Date: Thu, 5 Mar 2020 17:25:29 -0800
4 Subject: [PATCH] ls: restore 8.31 behavior on removed directories
7 * src/ls.c: Do not include <sys/sycall.h>
8 (print_dir): Don't worry about whether the directory is removed.
9 * tests/ls/removed-directory.sh: Adjust to match new (i.e., old)
13 src/ls.c | 22 ----------------------
14 tests/ls/removed-directory.sh | 10 ++--------
15 3 files changed, 8 insertions(+), 30 deletions(-)
17 diff --git a/NEWS b/NEWS
18 index fdc8bf5db..653e7178b 100644
21 @@ -2,6 +2,12 @@ GNU coreutils NEWS -*- outline -*-
23 * Noteworthy changes in release ?.? (????-??-??) [?]
25 +** Changes in behavior
27 + On GNU/Linux systems, ls no longer issues an error message on
28 + directory merely because it was removed. This reverts a change
29 + that was made in release 8.32.
32 * Noteworthy changes in release 8.32 (2020-03-05) [stable]
34 diff --git a/src/ls.c b/src/ls.c
35 index 24b983287..4acf5f44d 100644
39 # include <sys/ptem.h>
43 -# include <sys/syscall.h>
49 @@ -2896,7 +2892,6 @@ print_dir (char const *name, char const *realname, bool command_line_arg)
51 uintmax_t total_blocks = 0;
52 static bool first = true;
53 - bool found_any_entries = false;
56 dirp = opendir (name);
57 @@ -2972,7 +2967,6 @@ print_dir (char const *name, char const *realname, bool command_line_arg)
58 next = readdir (dirp);
61 - found_any_entries = true;
62 if (! file_ignored (next->d_name))
64 enum filetype type = unknown;
65 @@ -3018,22 +3012,6 @@ print_dir (char const *name, char const *realname, bool command_line_arg)
66 if (errno != EOVERFLOW)
70 - else if (! found_any_entries)
72 - /* If readdir finds no directory entries at all, not even "." or
73 - "..", then double check that the directory exists. */
74 - if (syscall (SYS_getdents, dirfd (dirp), NULL, 0) == -1
77 - /* We exclude EINVAL as that pertains to buffer handling,
78 - and we've passed NULL as the buffer for simplicity.
79 - ENOENT is returned if appropriate before buffer handling. */
80 - file_failure (command_line_arg, _("reading directory %s"), name);
88 diff --git a/tests/ls/removed-directory.sh b/tests/ls/removed-directory.sh
89 index e8c835dab..fe8f929a1 100755
90 --- a/tests/ls/removed-directory.sh
91 +++ b/tests/ls/removed-directory.sh
92 @@ -26,20 +26,14 @@ case $host_triplet in
93 *) skip_ 'non linux kernel' ;;
98 -cat <<\EOF >exp-err || framework_failure_
99 -ls: reading directory '.': No such file or directory
103 mkdir d || framework_failure_
104 cd d || framework_failure_
105 rmdir ../d || framework_failure_
107 -returns_ $LS_FAILURE ls >../out 2>../err || fail=1
108 +ls >../out 2>../err || fail=1
109 cd "$cwd" || framework_failure_
110 compare /dev/null out || fail=1
111 -compare exp-err err || fail=1
112 +compare /dev/null err || fail=1