ftw/nftw -- filesystem tree walk

Hi,

I recently experimented with ftw() and nftw(). These are function for calling some function for every
file in a subtree.
I need to get full information about type of file.
Almost everything is working according to documentation
but I noticed following problem:

With a value FTW_PHYS as 4th arg. for nftw() the callback should obtain FTW_SL for proper symbolic links and FTW_SLN for dangling ones. I always obtain FTW_SL - this is bug in my opinion.

So I need to supply 0 as 4th arg. Then callbacks [correctly] obtain FTW_F for proper symbolic links and FTW_SLN for dangling ones. Unfortunately 'struct stat' callback obtains also returns same 'st_mode' value for regular files and symbolic links (due to stat() instead of lstat() in implementation probably) and I need to call lstat() additionally. This workaround works.

Have anybody obtained FTW_SLN in FTW_PHYS mode?
I am using glibc 2.3.5 and have not found any information about bugs.

thanks,

What hardware platform and OS are you talking about? Otherwise your program is reporting the correct thing. If the FTW_PHYS flag is given as the 4th argument...FTW_SL files will be reported but not FTW_SLN types unless the 4th arg is not FTW_PHYS.

I am using Slackware Linux 10.2 / glibc 2.3.5 (PC machine).

From the 'info' documentation:

>\`FTW_PHYS'
      >While traversing the directory symbolic links are not
      >followed.  Instead symbolic links are reported using the
      >\`FTW_SL' value for the type parameter to the callback
      >function.  If the file referenced by a symbolic link does  not
      >exist \`FTW_SLN' is returned instead.

Therefore I understand with FTW_PHYS I will have FTW_SL or FTW_SLN given correctly, and FTW_F cannot happen for links.