![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| High Level Programming Post questions about C, C++, Java, SQL, and other programming languages here. |
|
|
||||
| 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 |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
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, |
| Forum Sponsor | ||
|
|
|
#2
|
|||
|
|||
|
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.
|
|
#3
|
|||
|
|||
|
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. |
|||
| Google The UNIX and Linux Forums |