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)
11 Signed-off-by: Joao Marcos Costa <joaomarcos.costa@bootlin.com>
14 src/ls.c | 22 ----------------------
15 tests/ls/removed-directory.sh | 10 ++--------
16 3 files changed, 8 insertions(+), 30 deletions(-)
18 diff --git a/NEWS b/NEWS
19 index fdc8bf5db..653e7178b 100644
22 @@ -2,6 +2,12 @@ GNU coreutils NEWS -*- outline -*-
24 * Noteworthy changes in release ?.? (????-??-??) [?]
26 +** Changes in behavior
28 + On GNU/Linux systems, ls no longer issues an error message on
29 + directory merely because it was removed. This reverts a change
30 + that was made in release 8.32.
33 * Noteworthy changes in release 8.32 (2020-03-05) [stable]
35 diff --git a/src/ls.c b/src/ls.c
36 index 24b983287..4acf5f44d 100644
40 # include <sys/ptem.h>
44 -# include <sys/syscall.h>
50 @@ -2896,7 +2892,6 @@ print_dir (char const *name, char const *realname, bool command_line_arg)
52 uintmax_t total_blocks = 0;
53 static bool first = true;
54 - bool found_any_entries = false;
57 dirp = opendir (name);
58 @@ -2972,7 +2967,6 @@ print_dir (char const *name, char const *realname, bool command_line_arg)
59 next = readdir (dirp);
62 - found_any_entries = true;
63 if (! file_ignored (next->d_name))
65 enum filetype type = unknown;
66 @@ -3018,22 +3012,6 @@ print_dir (char const *name, char const *realname, bool command_line_arg)
67 if (errno != EOVERFLOW)
71 - else if (! found_any_entries)
73 - /* If readdir finds no directory entries at all, not even "." or
74 - "..", then double check that the directory exists. */
75 - if (syscall (SYS_getdents, dirfd (dirp), NULL, 0) == -1
78 - /* We exclude EINVAL as that pertains to buffer handling,
79 - and we've passed NULL as the buffer for simplicity.
80 - ENOENT is returned if appropriate before buffer handling. */
81 - file_failure (command_line_arg, _("reading directory %s"), name);
89 diff --git a/tests/ls/removed-directory.sh b/tests/ls/removed-directory.sh
90 index e8c835dab..fe8f929a1 100755
91 --- a/tests/ls/removed-directory.sh
92 +++ b/tests/ls/removed-directory.sh
93 @@ -26,20 +26,14 @@ case $host_triplet in
94 *) skip_ 'non linux kernel' ;;
99 -cat <<\EOF >exp-err || framework_failure_
100 -ls: reading directory '.': No such file or directory
104 mkdir d || framework_failure_
105 cd d || framework_failure_
106 rmdir ../d || framework_failure_
108 -returns_ $LS_FAILURE ls >../out 2>../err || fail=1
109 +ls >../out 2>../err || fail=1
110 cd "$cwd" || framework_failure_
111 compare /dev/null out || fail=1
112 -compare exp-err err || fail=1
113 +compare /dev/null err || fail=1