All of lore.kernel.org
 help / color / mirror / Atom feed
* readdir() loses entries on ramfs and tmpfs
@ 2001-12-27  0:50 Pavel Roskin
  2001-12-27  1:52 ` Edgar Toernig
  2001-12-27  3:08 ` Legacy Fishtank
  0 siblings, 2 replies; 3+ messages in thread
From: Pavel Roskin @ 2001-12-27  0:50 UTC (permalink / raw)
  To: linux-kernel, linux-fsdevel

Hello!

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.

I could reproduce the problem on 2.4.18-pre1 compiled with gcc-2.96 from
RedHat 7.2.

I have reduced the problem to a simple test.  This script creates 
directories dir, dir/0, ... dir/168

=========================
#!/bin/sh
rm -rf dir
mkdir dir
i=0
while test $i != 169; do
  mkdir dir/$i
  i=$(($i+1))
done
=========================

And this C program tries to remove all subdirectories under "dir":

=========================
#include <stdio.h>
#include <unistd.h>
#include <dirent.h>
int main()
{
    DIR *dir;
    struct dirent *d;
    if (chdir("dir") != 0)
	return 1;
    dir = opendir(".");
    if (!dir)
	return 2;
    while ((d = readdir(dir)) != NULL) {
	printf("%s\n", d->d_name);
	rmdir(d->d_name);
    }
    closedir(dir);
    return 0;
}
=========================

This program succeeds on vfat and ext3 but it fails to remove "dir/0" on 
ramfs and tmpfs.

169 is not a random number.  It's the minimal number required to reproduce 
the problem.  Maybe other systems need another value.

Basically, removing a subdirectory in a directory open with opendir() 
causes an entry (file or directory) 168 entries later to be skipped by 
readdir().

I'm sorry, I cannot elaborate more, but the issue seems to be very 
serious.

-- 
Regards,
Pavel Roskin


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2001-12-27  3:08 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2001-12-27  0:50 readdir() loses entries on ramfs and tmpfs Pavel Roskin
2001-12-27  1:52 ` Edgar Toernig
2001-12-27  3:08 ` Legacy Fishtank

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.