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  <[EMAIL PROTECTED]>
_______________________________________________
[EMAIL PROTECTED] mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to "[EMAIL PROTECTED]"

Reply via email to