gnu: Add kafs-client
[jackhill/guix/guix.git] / gnu / packages / patches / coreutils-ls.patch
CommitLineData
02043f36
MO
1Patch taken from upstream to fix cross-compilation for aarch64. This can be
2removed on the next coreutils release.
3
4From 10fcb97bd728f09d4a027eddf8ad2900f0819b0a Mon Sep 17 00:00:00 2001
5From: Paul Eggert <eggert@cs.ucla.edu>
6Date: Thu, 5 Mar 2020 17:25:29 -0800
7Subject: [PATCH] ls: restore 8.31 behavior on removed directories
8
9* NEWS: Mention this.
10* src/ls.c: Do not include <sys/sycall.h>
11(print_dir): Don't worry about whether the directory is removed.
12* tests/ls/removed-directory.sh: Adjust to match new (i.e., old)
13behavior.
14---
15 NEWS | 6 ++++++
16 src/ls.c | 22 ----------------------
17 tests/ls/removed-directory.sh | 10 ++--------
18 3 files changed, 8 insertions(+), 30 deletions(-)
19
20diff --git a/NEWS b/NEWS
21index fdc8bf5db..653e7178b 100644
22--- a/NEWS
23+++ b/NEWS
24@@ -2,6 +2,12 @@ GNU coreutils NEWS -*- outline -*-
25
26 * Noteworthy changes in release ?.? (????-??-??) [?]
27
28+** Changes in behavior
29+
30+ On GNU/Linux systems, ls no longer issues an error message on
31+ directory merely because it was removed. This reverts a change
32+ that was made in release 8.32.
33+
34
35 * Noteworthy changes in release 8.32 (2020-03-05) [stable]
36
37diff --git a/src/ls.c b/src/ls.c
38index 24b983287..4acf5f44d 100644
39--- a/src/ls.c
40+++ b/src/ls.c
41@@ -49,10 +49,6 @@
42 # include <sys/ptem.h>
43 #endif
44
45-#ifdef __linux__
46-# include <sys/syscall.h>
47-#endif
48-
49 #include <stdio.h>
50 #include <assert.h>
51 #include <setjmp.h>
52@@ -2896,7 +2892,6 @@ print_dir (char const *name, char const *realname, bool command_line_arg)
53 struct dirent *next;
54 uintmax_t total_blocks = 0;
55 static bool first = true;
56- bool found_any_entries = false;
57
58 errno = 0;
59 dirp = opendir (name);
60@@ -2972,7 +2967,6 @@ print_dir (char const *name, char const *realname, bool command_line_arg)
61 next = readdir (dirp);
62 if (next)
63 {
64- found_any_entries = true;
65 if (! file_ignored (next->d_name))
66 {
67 enum filetype type = unknown;
68@@ -3018,22 +3012,6 @@ print_dir (char const *name, char const *realname, bool command_line_arg)
69 if (errno != EOVERFLOW)
70 break;
71 }
72-#ifdef __linux__
73- else if (! found_any_entries)
74- {
75- /* If readdir finds no directory entries at all, not even "." or
76- "..", then double check that the directory exists. */
77- if (syscall (SYS_getdents, dirfd (dirp), NULL, 0) == -1
78- && errno != EINVAL)
79- {
80- /* We exclude EINVAL as that pertains to buffer handling,
81- and we've passed NULL as the buffer for simplicity.
82- ENOENT is returned if appropriate before buffer handling. */
83- file_failure (command_line_arg, _("reading directory %s"), name);
84- }
85- break;
86- }
87-#endif
88 else
89 break;
90
91diff --git a/tests/ls/removed-directory.sh b/tests/ls/removed-directory.sh
92index e8c835dab..fe8f929a1 100755
93--- a/tests/ls/removed-directory.sh
94+++ b/tests/ls/removed-directory.sh
95@@ -26,20 +26,14 @@ case $host_triplet in
96 *) skip_ 'non linux kernel' ;;
97 esac
98
99-LS_FAILURE=2
100-
101-cat <<\EOF >exp-err || framework_failure_
102-ls: reading directory '.': No such file or directory
103-EOF
104-
105 cwd=$(pwd)
106 mkdir d || framework_failure_
107 cd d || framework_failure_
108 rmdir ../d || framework_failure_
109
110-returns_ $LS_FAILURE ls >../out 2>../err || fail=1
111+ls >../out 2>../err || fail=1
112 cd "$cwd" || framework_failure_
113 compare /dev/null out || fail=1
114-compare exp-err err || fail=1
115+compare /dev/null err || fail=1
116
117 Exit $fail