1 From 8c022656320592dbad146f5d3a3ae1875f419446 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 1/2] 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)
12 Upstream-commit: 10fcb97bd728f09d4a027eddf8ad2900f0819b0a
13 Signed-off-by: Kamil Dudka <kdudka@redhat.com>
15 src/ls.c | 22 ----------------------
16 tests/ls/removed-directory.sh | 10 ++--------
17 2 files changed, 2 insertions(+), 30 deletions(-)
19 diff --git a/src/ls.c b/src/ls.c
20 index 9d25f62..850ecc2 100644
24 # include <sys/ptem.h>
28 -# include <sys/syscall.h>
34 @@ -2896,7 +2892,6 @@ print_dir (char const *name, char const *realname, bool command_line_arg)
36 uintmax_t total_blocks = 0;
37 static bool first = true;
38 - bool found_any_entries = false;
41 dirp = opendir (name);
42 @@ -2972,7 +2967,6 @@ print_dir (char const *name, char const *realname, bool command_line_arg)
43 next = readdir (dirp);
46 - found_any_entries = true;
47 if (! file_ignored (next->d_name))
49 enum filetype type = unknown;
50 @@ -3018,22 +3012,6 @@ print_dir (char const *name, char const *realname, bool command_line_arg)
51 if (errno != EOVERFLOW)
55 - else if (! found_any_entries)
57 - /* If readdir finds no directory entries at all, not even "." or
58 - "..", then double check that the directory exists. */
59 - if (syscall (SYS_getdents, dirfd (dirp), NULL, 0) == -1
62 - /* We exclude EINVAL as that pertains to buffer handling,
63 - and we've passed NULL as the buffer for simplicity.
64 - ENOENT is returned if appropriate before buffer handling. */
65 - file_failure (command_line_arg, _("reading directory %s"), name);
73 diff --git a/tests/ls/removed-directory.sh b/tests/ls/removed-directory.sh
74 index e8c835d..fe8f929 100755
75 --- a/tests/ls/removed-directory.sh
76 +++ b/tests/ls/removed-directory.sh
77 @@ -26,20 +26,14 @@ case $host_triplet in
78 *) skip_ 'non linux kernel' ;;
83 -cat <<\EOF >exp-err || framework_failure_
84 -ls: reading directory '.': No such file or directory
88 mkdir d || framework_failure_
89 cd d || framework_failure_
90 rmdir ../d || framework_failure_
92 -returns_ $LS_FAILURE ls >../out 2>../err || fail=1
93 +ls >../out 2>../err || fail=1
94 cd "$cwd" || framework_failure_
95 compare /dev/null out || fail=1
96 -compare exp-err err || fail=1
97 +compare /dev/null err || fail=1
104 From 847324a0debd9d12062c79e7a7a9d3d8ce76390d Mon Sep 17 00:00:00 2001
105 From: Paul Eggert <eggert@cs.ucla.edu>
106 Date: Sat, 7 Mar 2020 10:29:51 -0800
107 Subject: [PATCH 2/2] ls: improve removed-directory test
109 * tests/ls/removed-directory.sh: Remove host_triplet test.
110 Skip this test if one cannot remove the working directory.
111 From a suggestion by Bernhard Voelker (Bug#39929).
113 Upstream-commit: 672819c73f2e94e61386dc0584bddf9da860cc26
114 Signed-off-by: Kamil Dudka <kdudka@redhat.com>
116 tests/ls/removed-directory.sh | 13 ++++---------
117 1 file changed, 4 insertions(+), 9 deletions(-)
119 diff --git a/tests/ls/removed-directory.sh b/tests/ls/removed-directory.sh
120 index fe8f929..63b209d 100755
121 --- a/tests/ls/removed-directory.sh
122 +++ b/tests/ls/removed-directory.sh
125 -# If ls is asked to list a removed directory (e.g. the parent process's
126 -# current working directory that has been removed by another process), it
127 -# emits an error message.
128 +# If ls is asked to list a removed directory (e.g., the parent process's
129 +# current working directory has been removed by another process), it
130 +# should not emit an error message merely because the directory is removed.
132 # Copyright (C) 2020 Free Software Foundation, Inc.
135 . "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
138 -case $host_triplet in
140 - *) skip_ 'non linux kernel' ;;
144 mkdir d || framework_failure_
145 cd d || framework_failure_
146 -rmdir ../d || framework_failure_
147 +rmdir ../d || skip_ "can't remove working directory on this platform"
149 ls >../out 2>../err || fail=1
150 cd "$cwd" || framework_failure_