diff options
author | Andreas Gruenbacher <agruen@gnu.org> | 2015-02-10 22:31:56 +0100 |
---|---|---|
committer | Andreas Gruenbacher <agruen@gnu.org> | 2015-02-10 22:31:56 +0100 |
commit | 8d12036047eb6cba16d3ae3f6b43c789d8378462 (patch) | |
tree | 92c07dc805469de081e82eb92ae7f195b012e7b3 | |
parent | 7297352e16bdd22c2c0842aebdf612d40271b75d (diff) | |
download | patch-8d12036047eb6cba16d3ae3f6b43c789d8378462.tar.gz |
Fix symlinks test case on some architectures
* src/safe.c: Include util.h for say(). Define EFTYPE if it isn't defined
already.
(traverse_another_path): When openat fails, also check for EMLINK, EFTYPE, and
ENOTDIR. Change the error message to "file ... is not a directory" and only
skip the rest of the patch instead of aborting.
* tests/symlinks: Update.
-rw-r--r-- | src/safe.c | 17 | ||||
-rw-r--r-- | tests/symlinks | 5 |
2 files changed, 16 insertions, 6 deletions
@@ -39,6 +39,12 @@ #define XTERN extern #include "common.h" +#include "util.h" + +#ifndef EFTYPE +# define EFTYPE 0 +#endif + /* Path lookup results are cached in a hash table + LRU list. When the cache is full, the oldest entries are removed. */ @@ -278,11 +284,14 @@ static int traverse_another_path (const char **pathname, int keepfd) printf (" (failed)\n"); fflush (stdout); } - if (errno == ELOOP) + if (errno == ELOOP + || errno == EMLINK /* FreeBSD 10.1: Too many links */ + || errno == EFTYPE /* NetBSD 6.1: Inappropriate file type or format */ + || errno == ENOTDIR) { - fprintf (stderr, "Refusing to follow symbolic link %.*s\n", - (int) (path - *pathname), *pathname); - fatal_exit (0); + say ("file %.*s is not a directory\n", + (int) (path - *pathname), *pathname); + skip_rest_of_patch = true; } return dirfd; } diff --git a/tests/symlinks b/tests/symlinks index f93f1cc..4383a49 100644 --- a/tests/symlinks +++ b/tests/symlinks @@ -196,8 +196,9 @@ EOF check 'patch -f -p1 < follow-symlink.diff || echo "Status: $?"' <<EOF patching symbolic link dir/foo -Refusing to follow symbolic link dir/foo -Status: 2 +file dir/foo is not a directory +1 out of 1 hunk ignored +Status: 1 EOF cat > bad-symlink-target1.diff <<EOF |