public inbox for libc-hacker@sourceware.org
 help / color / mirror / Atom feed
From: Jakub Jelinek <jakub@redhat.com>
To: Ulrich Drepper <drepper@redhat.com>, Roland McGrath <roland@redhat.com>
Cc: Glibc hackers <libc-hacker@sources.redhat.com>
Subject: [PATCH] Fix ftw
Date: Thu, 02 Mar 2006 15:53:00 -0000	[thread overview]
Message-ID: <20060302155329.GQ30252@sunsite.mff.cuni.cz> (raw)

Hi!

If dir->streamfd != -1 and
FXSTATAT (_STAT_VER, dir->streamfd, name, &st, 0);
fails with EACCESS or ENOENT, then ftw is supposed to
find out if that is because of a dead symlink or for some
other reason.  If d_type is DT_LNK, then no further
work is needed, however otherwise we were calling LXSTAT.
But name in this case is relative to dir->streamfd, not absolute
or relative to current working directory, so it tells us something
different from what we are looking for.
The following patch fixes it (tested on s390x where ftwtest failed
because of this).

2006-03-02  Jakub Jelinek  <jakub@redhat.com>

	* io/ftw.c (process_entry): If dir->streamfd != -1,
	use FXSTATAT rather than LXSTAT to find if unstatable
	file is a dead symlink.

--- libc/io/ftw.c.jj	2006-02-12 16:40:36.000000000 -0500
+++ libc/io/ftw.c	2006-03-02 10:37:41.000000000 -0500
@@ -419,13 +419,22 @@ process_entry (struct ftw_data *data, st
     {
       if (errno != EACCES && errno != ENOENT)
 	result = -1;
-      else if (!(data->flags & FTW_PHYS)
-	       && (d_type == DT_LNK
-		   || (LXSTAT (_STAT_VER, name, &st) == 0
-		       && S_ISLNK (st.st_mode))))
+      else if (data->flags & FTW_PHYS)
+	flag = FTW_NS;
+      else if (d_type == DT_LNK)
 	flag = FTW_SLN;
       else
-	flag = FTW_NS;
+	{
+	  if (dir->streamfd != -1)
+	    statres = FXSTATAT (_STAT_VER, dir->streamfd, name, &st,
+				AT_SYMLINK_NOFOLLOW);
+	  else
+	    statres = LXSTAT (_STAT_VER, name, &st);
+	  if (statres == 0 && S_ISLNK (st.st_mode))
+	    flag = FTW_SLN;
+	  else
+	    flag = FTW_NS;
+	}
     }
   else
     {

	Jakub

             reply	other threads:[~2006-03-02 15:53 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-03-02 15:53 Jakub Jelinek [this message]
2006-03-02 16:34 ` Ulrich Drepper
  -- strict thread matches above, loose matches on Subject: below --
2003-11-04 19:42 Jakub Jelinek

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20060302155329.GQ30252@sunsite.mff.cuni.cz \
    --to=jakub@redhat.com \
    --cc=drepper@redhat.com \
    --cc=libc-hacker@sources.redhat.com \
    --cc=roland@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).