Blame SOURCES/coreutils-8.32-ls-removed-dir.patch

04161d
From 8c022656320592dbad146f5d3a3ae1875f419446 Mon Sep 17 00:00:00 2001
04161d
From: Paul Eggert <eggert@cs.ucla.edu>
04161d
Date: Thu, 5 Mar 2020 17:25:29 -0800
04161d
Subject: [PATCH 1/2] ls: restore 8.31 behavior on removed directories
04161d
04161d
* NEWS: Mention this.
04161d
* src/ls.c: Do not include <sys/sycall.h>
04161d
(print_dir): Don't worry about whether the directory is removed.
04161d
* tests/ls/removed-directory.sh: Adjust to match new (i.e., old)
04161d
behavior.
04161d
04161d
Upstream-commit: 10fcb97bd728f09d4a027eddf8ad2900f0819b0a
04161d
Signed-off-by: Kamil Dudka <kdudka@redhat.com>
04161d
---
04161d
 src/ls.c                      | 22 ----------------------
04161d
 tests/ls/removed-directory.sh | 10 ++--------
04161d
 2 files changed, 2 insertions(+), 30 deletions(-)
04161d
04161d
diff --git a/src/ls.c b/src/ls.c
04161d
index 9d25f62..850ecc2 100644
04161d
--- a/src/ls.c
04161d
+++ b/src/ls.c
04161d
@@ -49,10 +49,6 @@
04161d
 # include <sys/ptem.h>
04161d
 #endif
04161d
 
04161d
-#ifdef __linux__
04161d
-# include <sys/syscall.h>
04161d
-#endif
04161d
-
04161d
 #include <stdio.h>
04161d
 #include <assert.h>
04161d
 #include <setjmp.h>
04161d
@@ -2896,7 +2892,6 @@ print_dir (char const *name, char const *realname, bool command_line_arg)
04161d
   struct dirent *next;
04161d
   uintmax_t total_blocks = 0;
04161d
   static bool first = true;
04161d
-  bool found_any_entries = false;
04161d
 
04161d
   errno = 0;
04161d
   dirp = opendir (name);
04161d
@@ -2972,7 +2967,6 @@ print_dir (char const *name, char const *realname, bool command_line_arg)
04161d
       next = readdir (dirp);
04161d
       if (next)
04161d
         {
04161d
-          found_any_entries = true;
04161d
           if (! file_ignored (next->d_name))
04161d
             {
04161d
               enum filetype type = unknown;
04161d
@@ -3018,22 +3012,6 @@ print_dir (char const *name, char const *realname, bool command_line_arg)
04161d
           if (errno != EOVERFLOW)
04161d
             break;
04161d
         }
04161d
-#ifdef __linux__
04161d
-      else if (! found_any_entries)
04161d
-        {
04161d
-          /* If readdir finds no directory entries at all, not even "." or
04161d
-             "..", then double check that the directory exists.  */
04161d
-          if (syscall (SYS_getdents, dirfd (dirp), NULL, 0) == -1
04161d
-              && errno != EINVAL)
04161d
-            {
04161d
-              /* We exclude EINVAL as that pertains to buffer handling,
04161d
-                 and we've passed NULL as the buffer for simplicity.
04161d
-                 ENOENT is returned if appropriate before buffer handling.  */
04161d
-              file_failure (command_line_arg, _("reading directory %s"), name);
04161d
-            }
04161d
-          break;
04161d
-        }
04161d
-#endif
04161d
       else
04161d
         break;
04161d
 
04161d
diff --git a/tests/ls/removed-directory.sh b/tests/ls/removed-directory.sh
04161d
index e8c835d..fe8f929 100755
04161d
--- a/tests/ls/removed-directory.sh
04161d
+++ b/tests/ls/removed-directory.sh
04161d
@@ -26,20 +26,14 @@ case $host_triplet in
04161d
   *) skip_ 'non linux kernel' ;;
04161d
 esac
04161d
 
04161d
-LS_FAILURE=2
04161d
-
04161d
-cat <<\EOF >exp-err || framework_failure_
04161d
-ls: reading directory '.': No such file or directory
04161d
-EOF
04161d
-
04161d
 cwd=$(pwd)
04161d
 mkdir d || framework_failure_
04161d
 cd d || framework_failure_
04161d
 rmdir ../d || framework_failure_
04161d
 
04161d
-returns_ $LS_FAILURE ls >../out 2>../err || fail=1
04161d
+ls >../out 2>../err || fail=1
04161d
 cd "$cwd" || framework_failure_
04161d
 compare /dev/null out || fail=1
04161d
-compare exp-err err || fail=1
04161d
+compare /dev/null err || fail=1
04161d
 
04161d
 Exit $fail
04161d
-- 
04161d
2.21.1
04161d
04161d
04161d
From 847324a0debd9d12062c79e7a7a9d3d8ce76390d Mon Sep 17 00:00:00 2001
04161d
From: Paul Eggert <eggert@cs.ucla.edu>
04161d
Date: Sat, 7 Mar 2020 10:29:51 -0800
04161d
Subject: [PATCH 2/2] ls: improve removed-directory test
04161d
04161d
* tests/ls/removed-directory.sh: Remove host_triplet test.
04161d
Skip this test if one cannot remove the working directory.
04161d
From a suggestion by Bernhard Voelker (Bug#39929).
04161d
04161d
Upstream-commit: 672819c73f2e94e61386dc0584bddf9da860cc26
04161d
Signed-off-by: Kamil Dudka <kdudka@redhat.com>
04161d
---
04161d
 tests/ls/removed-directory.sh | 13 ++++---------
04161d
 1 file changed, 4 insertions(+), 9 deletions(-)
04161d
04161d
diff --git a/tests/ls/removed-directory.sh b/tests/ls/removed-directory.sh
04161d
index fe8f929..63b209d 100755
04161d
--- a/tests/ls/removed-directory.sh
04161d
+++ b/tests/ls/removed-directory.sh
04161d
@@ -1,7 +1,7 @@
04161d
 #!/bin/sh
04161d
-# If ls is asked to list a removed directory (e.g. the parent process's
04161d
-# current working directory that has been removed by another process), it
04161d
-# emits an error message.
04161d
+# If ls is asked to list a removed directory (e.g., the parent process's
04161d
+# current working directory has been removed by another process), it
04161d
+# should not emit an error message merely because the directory is removed.
04161d
 
04161d
 # Copyright (C) 2020 Free Software Foundation, Inc.
04161d
 
04161d
@@ -21,15 +21,10 @@
04161d
 . "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
04161d
 print_ver_ ls
04161d
 
04161d
-case $host_triplet in
04161d
-  *linux*) ;;
04161d
-  *) skip_ 'non linux kernel' ;;
04161d
-esac
04161d
-
04161d
 cwd=$(pwd)
04161d
 mkdir d || framework_failure_
04161d
 cd d || framework_failure_
04161d
-rmdir ../d || framework_failure_
04161d
+rmdir ../d || skip_ "can't remove working directory on this platform"
04161d
 
04161d
 ls >../out 2>../err || fail=1
04161d
 cd "$cwd" || framework_failure_
04161d
-- 
04161d
2.21.1
04161d