Hello.
I wrote a simple disk scanner. It is supposed to replace `find` since one
can't force `find` to skip directories with given names. It is required, as
there are humongous directories with backup files and going through them
takes ages (they are on NFS volumes, which also must be scanned).
So I wrote this program, and run it on few Unix systems. Namely Fedora Core
3, Solaris 5.7, 5.9 and 5.10, AIX 4 and 5, Tru64, HPUX 10.20 and 11.11. So I
thought that everything will be fine on Mac OS X. I've started with 10.4,
leaving 1, 2 and 3 for "after succesfuly completed tests on 10.4."
And now I'm stucked. Issuing command:
find / -type f
results in about 4.7MB log (it's still not enough, check end of mail for
details). Scanning with my program, which is supposed to do the same
thing... never ends. I were able to create 7GB of log and my prog seems to
be stuck for some reason, like following symlinks. But I'm not.
My programs scans directories recursively, and hm... eagerly. That is:
scan(path) {
opendir(path);
while(readdir()) {
lstat(file);
if(regularfile)
printf(filename);
if(directory)
scan(filename);
// ignore all other types
}
}
It looks like first directory stream, that is one that is created for /
path, is running in loop! I've logged how it works, with "depth of call",
and same directories appear on same level forever and again.
I changed the program, so now it scans directory and saves names of entries
found and then checks whether given name is directory or regular file and
acts accordingly. It works now, but takes too much memory. I can reduce this
usage by saving only directories names, but still it seems like a very bad
idea.
What more, `find` utility scans only first three directories, and than
writes:
find: /dev/fd/4: No such file or directory
find: /Developer: No such file or directory
find: /encrypting: No such file or directory
find: /googlesearchwidget.zip.download: No such file or directory
find: /jd: No such file or directory
find: /Library: No such file or directory
find: /mnt: No such file or directory
find: /Network: No such file or directory
[ list goes on ]
My modified program scans all drives (nfs and hfs) and produces about 30MB
of logs. It seems that find has some problems too.
So, finally, the cry for help: HELP!
If someone have seen and defeated such a beast, please share your solution.
Thanks in advance,
JD