lkml.org 
[lkml]   [2001]   [Dec]   [26]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
Subjectreaddir() loses entries on ramfs and tmpfs
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

-
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/

\
 
 \ /
  Last update: 2005-03-22 13:14    [W:8.343 / U:0.016 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site