*BSD News Article 97816


Return to BSD News archive

Path: euryale.cc.adfa.oz.au!newshost.carno.net.au!harbinger.cc.monash.edu.au!munnari.OZ.AU!news.Hawaii.Edu!news.caldera.com!enews.sgi.com!news-feed.inet.tele.dk!cpk-news-hub1.bbnplanet.com!su-news-hub1.bbnplanet.com!news.bbnplanet.com!spring.edu.tw!feeder.seed.net.tw!reader.seed.net.tw!not-for-mail
From: gareth@eagle.seed.net.tw ()
Newsgroups: comp.unix.bsd.freebsd.misc
Subject: FreeBSD2.2.x nfs or kernel bug?
Date: 15 Jun 1997 17:29:08 GMT
Organization: SEEDNET InterNetNews News System
Lines: 75
Message-ID: <5o18p4$6vc@reader.seed.net.tw>
NNTP-Posting-Host: eagle.seed.net.tw
X-Newsreader: TIN [UNIX 1.3 950824BETA PL0]
Xref: euryale.cc.adfa.oz.au comp.unix.bsd.freebsd.misc:42993



  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[])
{

   if ( argc < 2 ) exit(-1);
   RemoveDir(argv[1]);
   return 1;
}
------------------------->end here<-------------------------------------