From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 21548 invoked by alias); 2 Mar 2006 15:53:40 -0000 Received: (qmail 21529 invoked by uid 22791); 2 Mar 2006 15:53:40 -0000 X-Spam-Check-By: sourceware.org Received: from sunsite.ms.mff.cuni.cz (HELO sunsite.mff.cuni.cz) (195.113.15.26) by sourceware.org (qpsmtpd/0.31) with ESMTP; Thu, 02 Mar 2006 15:53:38 +0000 Received: from sunsite.mff.cuni.cz (sunsite.mff.cuni.cz [127.0.0.1]) by sunsite.mff.cuni.cz (8.13.1/8.13.1) with ESMTP id k22FrThI017276; Thu, 2 Mar 2006 16:53:29 +0100 Received: (from jj@localhost) by sunsite.mff.cuni.cz (8.13.1/8.13.1/Submit) id k22FrTVw017275; Thu, 2 Mar 2006 16:53:29 +0100 Date: Thu, 02 Mar 2006 15:53:00 -0000 From: Jakub Jelinek To: Ulrich Drepper , Roland McGrath Cc: Glibc hackers Subject: [PATCH] Fix ftw Message-ID: <20060302155329.GQ30252@sunsite.mff.cuni.cz> Reply-To: Jakub Jelinek Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.4.1i Mailing-List: contact libc-hacker-help@sourceware.org; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-hacker-owner@sourceware.org X-SW-Source: 2006-03/txt/msg00019.txt.bz2 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 * 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