]>
Commit | Line | Data |
---|---|---|
88e8bf31 AF |
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 | |
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 | Signed-off-by: Joao Marcos Costa <joaomarcos.costa@bootlin.com> | |
12 | --- | |
13 | NEWS | 6 ++++++ | |
14 | src/ls.c | 22 ---------------------- | |
15 | tests/ls/removed-directory.sh | 10 ++-------- | |
16 | 3 files changed, 8 insertions(+), 30 deletions(-) | |
17 | ||
18 | diff --git a/NEWS b/NEWS | |
19 | index fdc8bf5db..653e7178b 100644 | |
20 | --- a/NEWS | |
21 | +++ b/NEWS | |
22 | @@ -2,6 +2,12 @@ GNU coreutils NEWS -*- outline -*- | |
23 | ||
24 | * Noteworthy changes in release ?.? (????-??-??) [?] | |
25 | ||
26 | +** Changes in behavior | |
27 | + | |
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. | |
31 | + | |
32 | ||
33 | * Noteworthy changes in release 8.32 (2020-03-05) [stable] | |
34 | ||
35 | diff --git a/src/ls.c b/src/ls.c | |
36 | index 24b983287..4acf5f44d 100644 | |
37 | --- a/src/ls.c | |
38 | +++ b/src/ls.c | |
39 | @@ -49,10 +49,6 @@ | |
40 | # include <sys/ptem.h> | |
41 | #endif | |
42 | ||
43 | -#ifdef __linux__ | |
44 | -# include <sys/syscall.h> | |
45 | -#endif | |
46 | - | |
47 | #include <stdio.h> | |
48 | #include <assert.h> | |
49 | #include <setjmp.h> | |
50 | @@ -2896,7 +2892,6 @@ print_dir (char const *name, char const *realname, bool command_line_arg) | |
51 | struct dirent *next; | |
52 | uintmax_t total_blocks = 0; | |
53 | static bool first = true; | |
54 | - bool found_any_entries = false; | |
55 | ||
56 | errno = 0; | |
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); | |
60 | if (next) | |
61 | { | |
62 | - found_any_entries = true; | |
63 | if (! file_ignored (next->d_name)) | |
64 | { | |
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) | |
68 | break; | |
69 | } | |
70 | -#ifdef __linux__ | |
71 | - else if (! found_any_entries) | |
72 | - { | |
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 | |
76 | - && errno != EINVAL) | |
77 | - { | |
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); | |
82 | - } | |
83 | - break; | |
84 | - } | |
85 | -#endif | |
86 | else | |
87 | break; | |
88 | ||
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' ;; | |
95 | esac | |
96 | ||
97 | -LS_FAILURE=2 | |
98 | - | |
99 | -cat <<\EOF >exp-err || framework_failure_ | |
100 | -ls: reading directory '.': No such file or directory | |
101 | -EOF | |
102 | - | |
103 | cwd=$(pwd) | |
104 | mkdir d || framework_failure_ | |
105 | cd d || framework_failure_ | |
106 | rmdir ../d || framework_failure_ | |
107 | ||
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 | |
114 | ||
115 | Exit $fail | |
116 | -- | |
117 | 2.17.1 | |
118 |