>From the manual:
"FTW_PHYS
If set, do not follow symbolic links. (This is what you want.) If not
set, symbolic links are followed, but no file is reported twice."
But:
[EMAIL PROTECTED]:~/programming/c/nftw_test$ cat nftw_test.c
#define _XOPEN_SOURCE 500
#include <ftw.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/stat.h>
int nftw_flags = 0;
void print_help_and_exit (char *arg) {
fprintf (stderr,
"Unrecognized option %s\n"
"nftw_test [-is] [-d D]\n"
"Tests FTW_PHYS.\n"
, arg);
exit (EXIT_FAILURE);
} // void print_help_and_exit ()
int fn (const char *fpath, const struct stat *sb, int typeflag, struct
FTW *notused) {
printf ("%s\n", fpath);
return 0;
} // int fn (const char *fpath, const struct stat *sb, int typeflag,
struct FTW *notused)
int main (int argc, char ** argv) {
char *dir = ".";
int i=1;
for (; i<argc; i++) {
if (strcmp(argv[i],"-d")==0) {
dir = argv[++i];
continue;
}
if (strcmp(argv[i],"-is")==0) {
nftw_flags = FTW_PHYS;
continue;
}
print_help_and_exit (argv[i]);
} // for
fprintf (stderr, "ntfw_flags == 0x%X\n", nftw_flags);
nftw (dir, fn, 1, nftw_flags);
return 0;
} // main
[EMAIL PROTECTED]:~/programming/c/nftw_test$ gcc -Wall nftw_test.c -o
nftw_test
[EMAIL PROTECTED]:~/programming/c/nftw_test$ find test/
test/
test/da
test/da/a
test/da/sym of a
test/sym of da
[EMAIL PROTECTED]:~/programming/c/nftw_test$ ./nftw_test -d test
ntfw_flags == 0x0
test
test/da
test/da/a
test/da/sym of a
[EMAIL PROTECTED]:~/programming/c/nftw_test$ ./nftw_test -is -d test
ntfw_flags == 0x1
test
test/da
test/da/a
test/da/sym of a
test/sym of da
[EMAIL PROTECTED]:~/programming/c/nftw_test$ stat test/da/sym\ of\ a
File: `test/da/sym of a' -> `a'
Size: 1 Blocks: 0 IO Block: 4096 link simbólico
Device: 805h/2053d Inode: 17769 Links: 1
Access: (0777/lrwxrwxrwx) Uid: ( 1000/ pedro) Gid: ( 1000/ pedro)
Access: 2008-01-25 08:39:53.000000000 -0200
Modify: 2008-01-25 07:43:19.000000000 -0200
Change: 2008-01-25 07:43:19.000000000 -0200
[EMAIL PROTECTED]:~/programming/c/nftw_test$ stat test/sym\ of\ da
File: `test/sym of da' -> `da'
Size: 2 Blocks: 0 IO Block: 4096 link simbólico
Device: 805h/2053d Inode: 17770 Links: 1
Access: (0777/lrwxrwxrwx) Uid: ( 1000/ pedro) Gid: ( 1000/ pedro)
Access: 2008-01-25 08:40:02.000000000 -0200
[EMAIL PROTECTED]:~/programming/c/nftw_test$
Is the above behavior correct?
I'm confused.