]>
Commit | Line | Data |
---|---|---|
89827d9a JP |
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 | |
5 | ||
6 | * NEWS: Mention this. | |
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) | |
10 | behavior. | |
11 | ||
12 | Upstream-commit: 10fcb97bd728f09d4a027eddf8ad2900f0819b0a | |
13 | Signed-off-by: Kamil Dudka <kdudka@redhat.com> | |
14 | --- | |
15 | src/ls.c | 22 ---------------------- | |
16 | tests/ls/removed-directory.sh | 10 ++-------- | |
17 | 2 files changed, 2 insertions(+), 30 deletions(-) | |
18 | ||
19 | diff --git a/src/ls.c b/src/ls.c | |
20 | index 9d25f62..850ecc2 100644 | |
21 | --- a/src/ls.c | |
22 | +++ b/src/ls.c | |
23 | @@ -49,10 +49,6 @@ | |
24 | # include <sys/ptem.h> | |
25 | #endif | |
26 | ||
27 | -#ifdef __linux__ | |
28 | -# include <sys/syscall.h> | |
29 | -#endif | |
30 | - | |
31 | #include <stdio.h> | |
32 | #include <assert.h> | |
33 | #include <setjmp.h> | |
34 | @@ -2896,7 +2892,6 @@ print_dir (char const *name, char const *realname, bool command_line_arg) | |
35 | struct dirent *next; | |
36 | uintmax_t total_blocks = 0; | |
37 | static bool first = true; | |
38 | - bool found_any_entries = false; | |
39 | ||
40 | errno = 0; | |
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); | |
44 | if (next) | |
45 | { | |
46 | - found_any_entries = true; | |
47 | if (! file_ignored (next->d_name)) | |
48 | { | |
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) | |
52 | break; | |
53 | } | |
54 | -#ifdef __linux__ | |
55 | - else if (! found_any_entries) | |
56 | - { | |
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 | |
60 | - && errno != EINVAL) | |
61 | - { | |
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); | |
66 | - } | |
67 | - break; | |
68 | - } | |
69 | -#endif | |
70 | else | |
71 | break; | |
72 | ||
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' ;; | |
79 | esac | |
80 | ||
81 | -LS_FAILURE=2 | |
82 | - | |
83 | -cat <<\EOF >exp-err || framework_failure_ | |
84 | -ls: reading directory '.': No such file or directory | |
85 | -EOF | |
86 | - | |
87 | cwd=$(pwd) | |
88 | mkdir d || framework_failure_ | |
89 | cd d || framework_failure_ | |
90 | rmdir ../d || framework_failure_ | |
91 | ||
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 | |
98 | ||
99 | Exit $fail | |
100 | -- | |
101 | 2.21.1 | |
102 | ||
103 | ||
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 | |
108 | ||
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). | |
112 | ||
113 | Upstream-commit: 672819c73f2e94e61386dc0584bddf9da860cc26 | |
114 | Signed-off-by: Kamil Dudka <kdudka@redhat.com> | |
115 | --- | |
116 | tests/ls/removed-directory.sh | 13 ++++--------- | |
117 | 1 file changed, 4 insertions(+), 9 deletions(-) | |
118 | ||
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 | |
123 | @@ -1,7 +1,7 @@ | |
124 | #!/bin/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. | |
131 | ||
132 | # Copyright (C) 2020 Free Software Foundation, Inc. | |
133 | ||
134 | @@ -21,15 +21,10 @@ | |
135 | . "${srcdir=.}/tests/init.sh"; path_prepend_ ./src | |
136 | print_ver_ ls | |
137 | ||
138 | -case $host_triplet in | |
139 | - *linux*) ;; | |
140 | - *) skip_ 'non linux kernel' ;; | |
141 | -esac | |
142 | - | |
143 | cwd=$(pwd) | |
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" | |
148 | ||
149 | ls >../out 2>../err || fail=1 | |
150 | cd "$cwd" || framework_failure_ | |
151 | -- | |
152 | 2.21.1 | |
153 |