Messages in this thread | | | Date | Wed, 26 Dec 2001 22:08:40 -0500 | From | Legacy Fishtank <> | Subject | Re: readdir() loses entries on ramfs and tmpfs |
| |
On Wed, Dec 26, 2001 at 07:50:11PM -0500, Pavel Roskin wrote: > I got a report that GNU Midnight Commander fails to erase some directories > on tmpfs from the first attempt. However, it succeeds the next time. [...] > while ((d = readdir(dir)) != NULL) { > printf("%s\n", d->d_name); > rmdir(d->d_name); > } [...] > I'm sorry, I cannot elaborate more, but the issue seems to be very > serious.
If Midnight Commander does similar to the above it's pretty silly...
In Perl I normally do something like this in a loop (with a max-loops limiter):
opendir @dirs = readdir(FOO); closedir last unless @dirs; &remove_the_dirs(@dirs);
Clearly that's slack since you could have a million files in a directory, but you see the point. readdir(2) and getdents(2) are inherently racy. If your code does not assume such and take appropriate action, it's broken.
Jeff
- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
| |