summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJim Meyering <meyering@redhat.com>2012-04-12 20:45:16 +0200
committerJim Meyering <meyering@redhat.com>2012-04-13 10:52:43 +0200
commit40679f5dbbb710bc3d09e0f410379fae20ba65e7 (patch)
tree24e9875a967184630f08a3879f7eabd9a42a4099
parent92449ffdc47f1e7dd01fbc110eb094977dafb66a (diff)
downloadgrep-40679f5dbbb710bc3d09e0f410379fae20ba65e7.tar.gz
grep: handle symlinked directory loops as usual
* src/main.c (grepfile): Treat EMLINK just like ELOOP, for systems like FreeBSD 9.0 on which we would otherwise report "Too many links" rather than ignoring that type of failure. E.g., "mkdir d; cd d; ln -s . a; grep -r ^" would print grep: a: Too many links and would exit with status 2. Now, it prints nothing and exits with status 1, as before. Reported by Nelson H. F. Beebe.
-rw-r--r--src/main.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/main.c b/src/main.c
index be1e2e6b..82cae33c 100644
--- a/src/main.c
+++ b/src/main.c
@@ -1311,7 +1311,7 @@ grepfile (int dirdesc, char const *name, int follow, int command_line)
int desc = openat_safer (dirdesc, name, O_RDONLY | (follow ? 0 : O_NOFOLLOW));
if (desc < 0)
{
- if (follow || errno != ELOOP)
+ if (follow || (errno != ELOOP && errno != EMLINK))
suppressible_error (filename, errno);
return 1;
}