[PATCHv2] nftw: fill in stat buf for dangling links [BZ #23501]

Andreas Schwab schwab@linux-m68k.org
Tue Jun 25 08:10:00 GMT 2019


On Jun 24 2019, DJ Delorie <dj@redhat.com> wrote:

> diff --git a/io/ftw.c b/io/ftw.c
> index 33e1a5ecab6..92e0119978b 100644
> --- a/io/ftw.c
> +++ b/io/ftw.c
> @@ -424,7 +424,21 @@ process_entry (struct ftw_data *data, struct dir_data *dir, const char *name,
>        else if (data->flags & FTW_PHYS)
>  	flag = FTW_NS;
>        else if (d_type == DT_LNK)
> -	flag = FTW_SLN;
> +	{
> +	  int err;
> +
> +	  flag = FTW_SLN;
> +
> +	  /* Old code left ST undefined; a clarification at the POSIX
> +	     level suggests it should contain information about the
> +	     link (ala lstat ()).  We do our best to fill in what data
> +	     we can.  */
> +	  if (dir->streamfd != -1)
> +	    FXSTATAT (_STAT_VER, dir->streamfd, name, &st,
> +		      AT_SYMLINK_NOFOLLOW);
> +	  else
> +	    LXSTAT (_STAT_VER, name, &st);
> +	}
>        else
>  	{
>  	  if (dir->streamfd != -1)

Just remove the branch that handles DT_LINK.  The last branch will do
the right thing.

Andreas.

-- 
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510  2552 DF73 E780 A9DA AEC1
"And now for something completely different."



More information about the Libc-alpha mailing list