Is there anyone has ideas about this problem? I wrote a simple
program to recursive traverse a NFS mounted directory and delete
files on FreeBSD 2.2.x (2.2R 2.2.1R), and gets kernel panic then
reboot after removing some files. If the traverse does not remove
files, the program runs well. I tested with the following cases
NFS server NFS client
2.1.x 2.1.x OK
2.2.x 2.1.x OK
2.1.x 2.2.x panic/reboot
2.2.x 2.2.x panic/reboot
Is there anyone has the same problem? To reproduce this problem,
the simplest way is to export a file system from local machine
and mount it with NFS mount.
The source code of this program is attached here. The directory
it traverses should be large enough to get the kernel panic. For
example. over 500 files.
#gcc -o myrm myrm.c
#myrm <test_dir>
------------------->> myrm.c cut here<<---------------------------------------
#include <sys/stat.h>
#include <dirent.h>
int RemoveDir(char *dir)
{
DIR *dirp;
struct dirent *dp;
struct stat stbuf;
chdir(dir);
if ( (dirp = opendir(".")) == NULL ){
perror("opendir()");
exit(-1);
}
while ( (dp = readdir(dirp)) != NULL ) {
if ( !strcmp(dp->d_name, ".") || !strcmp(dp->d_name, "..") )
continue;
if ( stat(dp->d_name, &stbuf) == -1 ) {
perror("state():");
continue;
}
if ( S_ISDIR(stbuf.st_mode) ){
RemoveDir(dp->d_name);
continue;
}
printf("unlink %s\n", dp->d_name);
unlink(dp->d_name);
}
closedir(dirp);
chdir("..");
rmdir(dir);
return 1;
int main(int argc, char *argv[])Quote:}
{
if ( argc < 2 ) exit(-1);
RemoveDir(argv[1]);
return 1;
------------------------->end here<-------------------------------------Quote:}