Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 20 Oct 2003 11:48:58 -0400
From:      "Matthew A Kolb" <muk@msu.edu>
To:        freebsd-hackers@freebsd.org
Subject:   nfs unlink confusion.
Message-ID:  <E1ABcHD-000GES-00@sys03.mail.msu.edu>

next in thread | raw e-mail | index | archive | help
I am having an anurism over this. 

Trying to opendir, readdir and unlink files in a directory over nfs
(with fbsd-current client and a variety of nfs servers (netapp, linux
fbsd)
seems to produce unexpected results. 

if i run this code: 

#include <sys/types.h>
#include <dirent.h>
#include <unistd.h>
#include <stdio.h> 

int
main(void)
{
       DIR *dirp;
       struct dirent *dire;
       int i = 0; 


       dirp=opendir(".");
       while ((dire=readdir(dirp)) != NULL)
       {
               i++;
               if (dire->d_name[0] == '.')
                       continue;
               if (unlink(dire->d_name) != 0)
                       fprintf(stderr, "boned. %s\n", dire->d_name);
       }
      closedir(dirp);
      fprintf(stderr, "i: %d\n", i);
      return(0);
} 

on a directory with 200 entries, I always end up with ~ 70 files
which are not unlinked.  unlink() never returns -1. 

when i run the same code on a linux nfs client, it works fine. 

if i run the code on a locally mounted ufs partition, it works fine. 

can someone fill me in here? 

am i doing something wrong? 

rm * in the directory removes all the files.  does fts_*() do some magic
to make sure this works (i.e. why does it work with rm, but not with
my code).  does this have to do with atomic unlink() over nfs? 

thanks for any help! 

./muk 

p.s. please cc me. 

-- 
m. kolb  <muk@msu.edu>



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?E1ABcHD-000GES-00>