bug-findutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH] Fix find -printf %Y on systems with fstatat().


From: Nick Alcock
Subject: [PATCH] Fix find -printf %Y on systems with fstatat().
Date: Wed, 06 Jun 2012 15:06:31 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.95 (gnu/linux)

We were dropping back to the fallback stat (which turns into an
fstatat() with O_NOFOLLOW) even when the return from fstatat()
indicated -ENOENT or -ELOOP, which should be preserved unchanged
so that the caller can print 'L' or 'N' accordingly.

* find/util.c (optionl_stat): Do not use the fallback stat
when -ENOENT or -ELOOP are encountered.
---
 ChangeLog   |    5 +++++
 find/util.c |    4 ++++
 2 files changed, 9 insertions(+)

diff --git a/ChangeLog b/ChangeLog
index 7f240a6..975c55d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2012-06-06  Nick Alcock  <address@hidden>
+
+       * find/util.c (optionl_stat): Do not use the fallback stat
+       when -ENOENT or -ELOOP are encountered.
+
 2011-12-30  Karl Berry  <address@hidden>
 
        Documentation improvements (UK spelling, use of @code).
diff --git a/find/util.c b/find/util.c
index 94e9549..e489b44 100644
--- a/find/util.c
+++ b/find/util.c
@@ -627,6 +627,10 @@ optionl_stat(const char *name, struct stat *p)
   rv = fstatat (state.cwd_dir_fd, name, p, 0);
   if (0 == rv)
     return 0;                  /* normal case. */
+  else if ((-1 == rv) &&
+          ((errno == ENOENT) ||
+           (errno == ELOOP)))
+    return -1;
   else
     return fallback_stat (name, p, rv);
 }
-- 
1.7.10.4.153.g8c399cf



reply via email to

[Prev in Thread] Current Thread [Next in Thread]