bug-findutils
[Top][All Lists]
Advanced

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

[PATCH 1/2] Fix Savannah bug 29460, -printf %Y fails in $CWD-dependent w


From: James Youngman
Subject: [PATCH 1/2] Fix Savannah bug 29460, -printf %Y fails in $CWD-dependent way
Date: Wed, 7 Apr 2010 10:56:23 +0100

* find/pred.c (do_fprintf): Use optionl_stat and optionp_stat
instead of stat and lstat, because the first two functions are
aware of state.cwd_dir_fd.
* find/testsuite/find.gnu/printf-nonlocal-symlink.exp: A new test
case for this bug.
* find/testsuite/find.gnu/printf-nonlocal-symlink.xo: Expected
output for this test.
* find/testsuite/Makefile.am (EXTRA_DIST_EXP): Add the new test
case.
(EXTRA_DIST_XO): Add the expected-output file.

Signed-off-by: James Youngman <address@hidden>
---
 ChangeLog                                          |   23 ++++++++++++++++++++
 NEWS                                               |    2 +
 find/pred.c                                        |    2 +-
 find/testsuite/Makefile.am                         |    2 +
 .../testsuite/find.gnu/printf-nonlocal-symlink.exp |    7 ++++++
 find/testsuite/find.gnu/printf-nonlocal-symlink.xo |    1 +
 6 files changed, 36 insertions(+), 1 deletions(-)
 create mode 100644 find/testsuite/find.gnu/printf-nonlocal-symlink.exp
 create mode 100644 find/testsuite/find.gnu/printf-nonlocal-symlink.xo

diff --git a/ChangeLog b/ChangeLog
index 4e712b9..bccfcb6 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,26 @@
+2010-04-07  James Youngman  <address@hidden>
+
+       More stat/xstat cleanup.
+       * find/parser.c (estimate_fstype_success_rate): Change the name of
+       the variable "dir" to "the_root_dir" to emphasise that it doesn't
+       matter that we're calling stat rather than options.xstat.
+       * find/ftsfind.c (symlink_loop): Call options.xstat instead of
+       stat/lstat, because options.xstat takes account of
+       state.cwd_dir_fd.
+
+       Fix Savannah bug 29460, -printf %Y fails in $CWD-dependent way
+       * find/pred.c (do_fprintf): Use optionl_stat and optionp_stat
+       instead of stat and lstat, because the first two functions are
+       aware of state.cwd_dir_fd.
+       * find/testsuite/find.gnu/printf-nonlocal-symlink.exp: A new test
+       case for this bug.
+       * find/testsuite/find.gnu/printf-nonlocal-symlink.xo: Expected
+       output for this test.
+       * find/testsuite/Makefile.am (EXTRA_DIST_EXP): Add the new test
+       case.
+       (EXTRA_DIST_XO): Add the expected-output file.
+       * NEWS: Mention this fix.
+
 2010-04-05  James Youngman  <address@hidden>
 
        Use set_program_name in regexprops.
diff --git a/NEWS b/NEWS
index 7b4112a..7a82f33 100644
--- a/NEWS
+++ b/NEWS
@@ -4,6 +4,8 @@ GNU findutils NEWS - User visible changes.      -*- outline -*- 
(allout)
 
 ** Bug Fixes
 
+#29460: -printf %Y fails in $CWD-dependent way
+
 #29435: fd_is_cloexec does not work on Fedora buildhosts
 
 #27213: avoid failed assertions for non-executable directories.
diff --git a/find/pred.c b/find/pred.c
index 29fad54..1e0e891 100644
--- a/find/pred.c
+++ b/find/pred.c
@@ -1030,7 +1030,7 @@ do_fprintf (struct format_val *dest,
                /* If we would normally follow links, do not do so.
                 * If we would normally not follow links, do so.
                 */
-               if ((following_links () ? lstat : stat)
+               if ((following_links () ? optionp_stat : optionl_stat)
                    (state.rel_pathname, &sbuf) != 0)
                  {
                    if ( errno == ENOENT )
diff --git a/find/testsuite/Makefile.am b/find/testsuite/Makefile.am
index 7f99dad..4ce87f6 100644
--- a/find/testsuite/Makefile.am
+++ b/find/testsuite/Makefile.am
@@ -48,6 +48,7 @@ find.gnu/posix-dflt.xo \
 find.gnu/posix-h.xo \
 find.gnu/posix-l.xo \
 find.gnu/printfHdfl.xo \
+find.gnu/printf-nonlocal-symlink.xo \
 find.gnu/printf-slash.xo \
 find.gnu/printf-symlink.xo \
 find.gnu/printf-h.xo \
@@ -160,6 +161,7 @@ find.gnu/posix-perminvalid.exp \
 find.gnu/printfHdfl.exp \
 find.gnu/printf.exp \
 find.gnu/printf.exp \
+find.gnu/printf-nonlocal-symlink.exp \
 find.gnu/printf-slash.exp \
 find.gnu/printf-symlink.exp \
 find.gnu/printf-h.exp \
diff --git a/find/testsuite/find.gnu/printf-nonlocal-symlink.exp 
b/find/testsuite/find.gnu/printf-nonlocal-symlink.exp
new file mode 100644
index 0000000..f8e61e1
--- /dev/null
+++ b/find/testsuite/find.gnu/printf-nonlocal-symlink.exp
@@ -0,0 +1,7 @@
+exec rm -rf tmp
+exec mkdir tmp
+exec mkdir tmp/foo
+exec touch tmp/foo/file
+exec ln -s file tmp/foo/LINK
+find_start p {tmp  -type l -printf "%p: %Y %y\n" }
+exec rm -rf tmp
diff --git a/find/testsuite/find.gnu/printf-nonlocal-symlink.xo 
b/find/testsuite/find.gnu/printf-nonlocal-symlink.xo
new file mode 100644
index 0000000..fcb338a
--- /dev/null
+++ b/find/testsuite/find.gnu/printf-nonlocal-symlink.xo
@@ -0,0 +1 @@
+tmp/foo/LINK: f l
-- 
1.7.0





reply via email to

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