From owner-freebsd-hackers@FreeBSD.ORG Mon Oct 20 08:49:00 2003 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id EEB6616A4B3 for ; Mon, 20 Oct 2003 08:49:00 -0700 (PDT) Received: from sys03.mail.msu.edu (sys03.mail.msu.edu [35.9.75.103]) by mx1.FreeBSD.org (Postfix) with ESMTP id 4F00A43FB1 for ; Mon, 20 Oct 2003 08:49:00 -0700 (PDT) (envelope-from muk@msu.edu) Received: from muk by sys03.mail.msu.edu with local (Exim 4.10 #3) (authenticated as muk) id 1ABcHD-000GES-00 for freebsd-hackers@freebsd.org; Mon, 20 Oct 2003 11:48:59 -0400 From: "Matthew A Kolb" To: freebsd-hackers@freebsd.org Date: Mon, 20 Oct 2003 11:48:58 -0400 Mime-Version: 1.0 Content-Type: text/plain; format=flowed; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Message-Id: Subject: nfs unlink confusion. X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 20 Oct 2003 15:49:01 -0000 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 #include #include #include 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