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