The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > High Level Programming
Google UNIX.COM


High Level Programming Post questions about C, C++, Java, SQL, and other programming languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Tree with UNIX gunbol Shell Programming and Scripting 5 04-09-2008 05:51 AM
MindTouch learns the open source walk iBot UNIX and Linux RSS News 0 03-07-2008 12:40 PM
directory tree ravi raj kumar Shell Programming and Scripting 3 01-24-2008 10:08 AM
implementing AVL tree arjunjag High Level Programming 1 07-09-2007 07:16 AM
directory as tree anything2 High Level Programming 2 03-01-2007 06:38 AM

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1  
Old 03-18-2008
Registered User
 

Join Date: Feb 2005
Posts: 53
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,
Reply With Quote
Forum Sponsor
  #2  
Old 03-18-2008
Registered User
 

Join Date: Oct 2007
Location: USA
Posts: 567
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.
Reply With Quote
  #3  
Old 03-18-2008
Registered User
 

Join Date: Feb 2005
Posts: 53
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.
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




All times are GMT -7. The time now is 06:31 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0