summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTavian Barnes <tavianator@tavianator.com>2024-06-03 18:30:09 -0400
committerTavian Barnes <tavianator@tavianator.com>2024-06-03 18:30:09 -0400
commit9e408d4bb50cb7c4e9d0a007b95f9fb9d32a16d0 (patch)
tree582082976f6d971928ccaed37e11d616e5378a98
parent6e4c3893ae4e053d571ee538f8b4dc4e6cfce658 (diff)
downloadbfs-3.3.1.tar.xz
Make ELOOP an error again, except for -xtype.3.3.1
POSIX requires an error if (for example) -L encounters a symlink loop. The GNU find change was restricted to -xtype, so add a manual ELOOP test to eval_xtype() for compatibility. This reverts commit 470589cbd9ca3e73d8c01ac3a96cbc065179dcc5. Link: https://savannah.gnu.org/bugs/?19605
-rw-r--r--Makefile2
-rw-r--r--docs/CHANGELOG.md12
-rw-r--r--src/bfstd.c2
-rw-r--r--src/eval.c7
-rw-r--r--tests/gnu/L_loops_continue.out1
-rw-r--r--tests/gnu/ignore_readdir_race_loop.out1
-rw-r--r--tests/gnu/xtype_l_loops.out3
-rw-r--r--tests/gnu/xtype_l_loops.sh1
8 files changed, 25 insertions, 4 deletions
diff --git a/Makefile b/Makefile
index cfefe62..e256ac7 100644
--- a/Makefile
+++ b/Makefile
@@ -74,7 +74,7 @@ gen/version.c.new::
elif test -e src/../.git && command -v git >/dev/null 2>&1; then \
git -C src/.. describe --always --dirty; \
else \
- echo "3.3"; \
+ echo "3.3.1"; \
fi | tr -d '\n' >>$@
@printf '";\n' >>$@
diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md
index 1d4bdcf..db978b8 100644
--- a/docs/CHANGELOG.md
+++ b/docs/CHANGELOG.md
@@ -1,6 +1,18 @@
3.*
===
+3.3.1
+-----
+
+**June 3, 2024**
+
+### Bug fixes
+
+- Reduced the scope of the symbolic link loop change in version 3.3.
+ `-xtype l` remains true for symbolic link loops, matching a change in GNU findutils 4.10.0.
+ However, `-L` will report an error, just like `bfs` prior to 3.3 and other `find` implementations, as required by POSIX.
+
+
3.3
---
diff --git a/src/bfstd.c b/src/bfstd.c
index 1c5e289..44eda7c 100644
--- a/src/bfstd.c
+++ b/src/bfstd.c
@@ -44,7 +44,7 @@ bool error_is_like(int error, int category) {
switch (category) {
case ENOENT:
- return error == ENOTDIR || error == ELOOP;
+ return error == ENOTDIR;
case ENOSYS:
// https://github.com/opencontainers/runc/issues/2151
diff --git a/src/eval.c b/src/eval.c
index 0495207..cef766d 100644
--- a/src/eval.c
+++ b/src/eval.c
@@ -999,6 +999,13 @@ bool eval_xtype(const struct bfs_expr *expr, struct bfs_eval *state) {
const struct BFTW *ftwbuf = state->ftwbuf;
enum bfs_stat_flags flags = ftwbuf->stat_flags ^ (BFS_STAT_NOFOLLOW | BFS_STAT_TRYFOLLOW);
enum bfs_type type = bftw_type(ftwbuf, flags);
+
+ // GNU find treats ELOOP as a broken symbolic link for -xtype l
+ // (but not -L -type l)
+ if ((flags & BFS_STAT_TRYFOLLOW) && type == BFS_ERROR && errno == ELOOP) {
+ type = BFS_LNK;
+ }
+
if (type == BFS_ERROR) {
eval_report_error(state);
return false;
diff --git a/tests/gnu/L_loops_continue.out b/tests/gnu/L_loops_continue.out
index faf33d3..a514555 100644
--- a/tests/gnu/L_loops_continue.out
+++ b/tests/gnu/L_loops_continue.out
@@ -4,7 +4,6 @@ loops/deeply
loops/deeply/nested
loops/deeply/nested/dir
loops/file
-loops/loop
loops/notdir
loops/skip
loops/skip/dir
diff --git a/tests/gnu/ignore_readdir_race_loop.out b/tests/gnu/ignore_readdir_race_loop.out
index faf33d3..a514555 100644
--- a/tests/gnu/ignore_readdir_race_loop.out
+++ b/tests/gnu/ignore_readdir_race_loop.out
@@ -4,7 +4,6 @@ loops/deeply
loops/deeply/nested
loops/deeply/nested/dir
loops/file
-loops/loop
loops/notdir
loops/skip
loops/skip/dir
diff --git a/tests/gnu/xtype_l_loops.out b/tests/gnu/xtype_l_loops.out
new file mode 100644
index 0000000..fdaccab
--- /dev/null
+++ b/tests/gnu/xtype_l_loops.out
@@ -0,0 +1,3 @@
+loops/broken
+loops/loop
+loops/notdir
diff --git a/tests/gnu/xtype_l_loops.sh b/tests/gnu/xtype_l_loops.sh
new file mode 100644
index 0000000..6893134
--- /dev/null
+++ b/tests/gnu/xtype_l_loops.sh
@@ -0,0 +1 @@
+bfs_diff loops -xtype l