[IGNORE THIS POST]
In my previous thread (http://cboard.cprogramming.com/showthread.php?t=104964) I was trying to find out why opendir would sometimes fail in a script which recurses thru a directory tree. No one could tell me so I wrote a simple test:
Code:
#include <stdio.h>
#include <string.h>
#include <dirent.h>
#include <errno.h>
int main (int argc, char *argv[]) {
struct dirent *dcon;
DIR *dir = opendir (argv[1]);
if (dir == NULL) {
printf ("%s: %s\n", argv[1], strerror(errno));
exit(1);
}
while (dcon = readdir (dir)) {
puts (dcon->d_name);
}
}
Low and behold, this fails on every fourth or five directory i try it on, regardless of the pathname, length, ownership, or permissions (the error is "No such file or directory"). Since zacs7 tested the other script and got the same result, it can't be filesystem corruption...however we both use linux/GNU and (I presume) the GNU C libraries.
Can anyone explain the problem?