> That's close. > To clarify: with the current fts implementation, the interval between the > initial lstat and subsequent open of the same directory may be arbitrarily > long, but only for 2nd or subsequent command-line arguments -- which > usually translates to 2nd or subsequent members of the argv array that > is passed to fts_open.
Here's a longer strace snippet for 'find /tmp/x' (find-4.3.1+patch). Note, that lstat("b") and open("b") could be arbitrarily far depending on the size of the tree under "a". open(".", O_RDONLY|O_LARGEFILE) = 3 fchdir(3) = 0 lstat64("/tmp/x", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0 open(".", O_RDONLY|O_NONBLOCK|O_NOCTTY|O_LARGEFILE|O_DIRECTORY) = 4 fchdir(4) = 0 fstat64(1, {st_mode=S_IFCHR|0666, st_rdev=makedev(1, 3), ...}) = 0 ioctl(1, SNDCTL_TMR_TIMEBASE or TCGETS, 0xbfd3f674) = -1 ENOTTY (Inappropriate ioctl for device) mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb7f2d000 open("/tmp/x", O_RDONLY|O_NONBLOCK|O_LARGEFILE|O_DIRECTORY) = 5 fstat64(5, {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0 fcntl64(5, F_SETFD, FD_CLOEXEC) = 0 fstat64(5, {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0 fchdir(5) = 0 getdents64(5, /* 7 entries */, 4096) = 168 lstat64("a", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0 lstat64("b", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0 getdents64(5, /* 0 entries */, 4096) = 0 close(5) = 0 lstat64("7", {st_mode=S_IFREG|0644, st_size=0, ...}) = 0 open("a", O_RDONLY|O_NONBLOCK|O_LARGEFILE|O_DIRECTORY) = 5 fstat64(5, {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0 fcntl64(5, F_SETFD, FD_CLOEXEC) = 0 fstat64(5, {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0 fchdir(5) = 0 getdents64(5, /* 5 entries */, 4096) = 120 getdents64(5, /* 0 entries */, 4096) = 0 close(5) = 0 lstat64("1", {st_mode=S_IFREG|0644, st_size=0, ...}) = 0 open("..", O_RDONLY|O_NONBLOCK|O_NOCTTY|O_LARGEFILE|O_DIRECTORY) = 5 fstat64(5, {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0 fchdir(5) = 0 close(5) = 0 open("b", O_RDONLY|O_NONBLOCK|O_LARGEFILE|O_DIRECTORY) = 5 fstat64(5, {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0 fcntl64(5, F_SETFD, FD_CLOEXEC) = 0 fstat64(5, {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0 fchdir(5) = 0 getdents64(5, /* 5 entries */, 4096) = 120 getdents64(5, /* 0 entries */, 4096) = 0 close(5) = 0 lstat64("4", {st_mode=S_IFREG|0644, st_size=0, ...}) = 0 open("..", O_RDONLY|O_NONBLOCK|O_NOCTTY|O_LARGEFILE|O_DIRECTORY) = 5 fstat64(5, {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0 fchdir(5) = 0 close(5) = 0 lstat64("8", {st_mode=S_IFREG|0644, st_size=0, ...}) = 0 fchdir(4) = 0 fchdir(4) = 0 close(4) = 0 write(1, "/tmp/x\n/tmp/x/7\n/tmp/x/a\n/tmp/x/"..., 118) = 118