03-18-2008
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,
8 More Discussions You Might Find Interesting
1. Programming
int ftw(const char *path, int(*func)(), int depth);
what does the third parameter(depth) mean?
the book said that the larger the value of depth, the fewer directories have to be reopened, therefore increasing the speed of the call.
how so?
thanks (1 Reply)
Discussion started by: bb00y
1 Replies
2. Programming
hello
im trying to find more information about the function: ftw()
however it seems every resource has the same thing
how to declare it and what it is supposed to do
does anyone know of a resource that actually has ftw used within a program, so i can get an idea of how to actually use it?... (0 Replies)
Discussion started by: runawayNinja
0 Replies
3. Programming
Hello,
I am looking for specific files in my tree directory using ftw(3). How do I know how deep I am in the file structure.. in other words, say I am looking for config.txt files, and my structure looks like this..
/some/directory/user1/config.txt
/some/directory/user2/config.txt
....... (2 Replies)
Discussion started by: germallon
2 Replies
4. Shell Programming and Scripting
Hi there,
i tried a lot of things actually to get my script running as expected.
Situation:
I have a config file with several parameters in the form
FFF.thisIsaParam=Value
FFF.included.AnotherPortofParam=Value
Additionally there are some comments in it.
Script should... (8 Replies)
Discussion started by: smhaller
8 Replies
5. UNIX for Dummies Questions & Answers
Hi,
I wanted to find out that in my database server which filesystems are shared storage and which filesystems are local. Like when I use df -k, it shows "filesystem" and "mounted on" but I want to know which one is shared and which one is local.
Please tell me the commands which I can run... (2 Replies)
Discussion started by: kamranjalal
2 Replies
6. AIX
Dear all,
We are facing prolem when we are going to mount AIX filesystem, the system returned the following error
0506-307The AFopen call failed
: A file or directory in the path name does not exist.
But when we ls filesystems in the /etc/ directory it show
-rw-r--r-- 0 root ... (2 Replies)
Discussion started by: m_raheelahmed
2 Replies
7. UNIX for Advanced & Expert Users
Hello unix.com Community:
I need help with writing a "common" script that can get the httpd installs by name and install directory|ies and tar.gz them up by name and point that tar operation to the matching install directory.
I have 2 Distros that I am concerned with for this task: CentOS and... (3 Replies)
Discussion started by: Habitual
3 Replies
8. HP-UX
We are using a third party to monitor unix servers performance since last 60 days, since last 3 days we are not able to get the performance alarms on our tool.
When we check the same with the tool team, they said "SNMP walk is not happening for all the servers."
Performance we mean... (9 Replies)
Discussion started by: marunmeera
9 Replies
ftw.h(3HEAD) Headers ftw.h(3HEAD)
NAME
ftw.h, ftw - file tree traversal
SYNOPSIS
#include <ftw.h>
DESCRIPTION
The <ftw.h> header defines the FTW structure that includes the following members:
int base
int level
The <ftw.h> header defines macros for use as values of the third argument to the application-supplied function that is passed as the sec-
ond argument to ftw() and nftw() (see ftw(3C)):
FTW_F file
FTW_D directory
FTW_DNR directory without read permission
FTW_DP directory with subdirectories visited
FTW_NS unknown type; stat() failed
FTW_SL symbolic link
FTW_SLN symbolic link that names a nonexistent file
The <ftw.h> header defines macros for use as values of the fourth argument to nftw():
FTW_PHYS Physical walk, does not follow symbolic links. Otherwise, nftw() follows links but does not walk down any path that crosses
itself.
FTW_MOUNT The walk does not cross a mount point.
FTW_DEPTH All subdirectories are visited before the directory itself.
FTW_CHDIR The walk changes to each direct ory before reading it.
The <ftw.h> header defines the stat structure and the symbolic names for st_mode and the file type test macros as described in
<sys/stat.h>.
Inclusion of the <ftw.h> header might also make visible all symbols from <sys/stat.h>.
ATTRIBUTES
See attributes(5) for descriptions of the following attributes:
+-----------------------------+-----------------------------+
| ATTRIBUTE TYPE | ATTRIBUTE VALUE |
+-----------------------------+-----------------------------+
|Interface Stability |Standard |
+-----------------------------+-----------------------------+
SEE ALSO
ftw(3C), stat.h(3HEAD), attributes(5), standards(5)
SunOS 5.10 10 Sep 2004 ftw.h(3HEAD)