From owner-freebsd-fs@freebsd.org Sun May 2 09:57:52 2021 Return-Path: Delivered-To: freebsd-fs@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 2055B5FF01C for ; Sun, 2 May 2021 09:57:52 +0000 (UTC) (envelope-from njm@njm.me.uk) Received: from smtp001-out.apm-internet.net (smtp001-out.apm-internet.net [85.119.248.222]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 4FY1kR0Hkdz4VyN for ; Sun, 2 May 2021 09:57:50 +0000 (UTC) (envelope-from njm@njm.me.uk) Received: (qmail 95190 invoked from network); 2 May 2021 09:57:49 -0000 X-APM-Out-ID: 16199494699518 X-APM-Authkey: 18389/1(18389/1) 4 Received: from unknown (HELO meld.njm.me.uk) (86.179.69.31) by smtp001.apm-internet.net with SMTP; 2 May 2021 09:57:49 -0000 Received: from triton.njm.me.uk (triton.njm.me.uk [192.168.144.133]) by meld.njm.me.uk (8.16.1/8.16.1) with ESMTPS id 1429vmMi095854 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sun, 2 May 2021 10:57:48 +0100 (BST) (envelope-from njm@njm.me.uk) Received: from localhost (localhost [127.0.0.1]) by triton.njm.me.uk (8.16.1/8.16.1) with ESMTP id 1429vlQZ088724; Sun, 2 May 2021 10:57:48 +0100 (BST) (envelope-from njm@njm.me.uk) Date: Sun, 02 May 2021 10:57:47 +0100 From: "N.J. Mann" To: Rick Macklem cc: freebsd-fs@freebsd.org Subject: Re: readdir() -> d_type always zero on NFS v3 mounted filesystems Message-ID: <362D4A23EABEC786267883FF@triton.njm.me.uk> In-Reply-To: References: <2E84A420CCC10A73504624DE@triton.njm.me.uk> X-Mailer: Mulberry/4.0.8 (Linux/x86) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Content-Disposition: inline X-Rspamd-Queue-Id: 4FY1kR0Hkdz4VyN X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org; dkim=none; dmarc=none; spf=none (mx1.freebsd.org: domain of njm@njm.me.uk has no SPF policy when checking 85.119.248.222) smtp.mailfrom=njm@njm.me.uk X-Spamd-Result: default: False [-2.20 / 15.00]; ARC_NA(0.00)[]; RBL_DBL_DONT_QUERY_IPS(0.00)[85.119.248.222:from]; NEURAL_HAM_MEDIUM(-1.00)[-1.000]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; MIME_GOOD(-0.10)[text/plain]; DMARC_NA(0.00)[njm.me.uk]; AUTH_NA(1.00)[]; SPAMHAUS_ZRD(0.00)[85.119.248.222:from:127.0.2.255]; RCVD_COUNT_THREE(0.00)[4]; TO_MATCH_ENVRCPT_SOME(0.00)[]; NEURAL_HAM_SHORT(-1.00)[-1.000]; RCPT_COUNT_TWO(0.00)[2]; R_SPF_NA(0.00)[no SPF record]; FROM_EQ_ENVFROM(0.00)[]; R_DKIM_NA(0.00)[]; MIME_TRACE(0.00)[0:+]; ASN(0.00)[asn:35259, ipnet:85.119.248.0/21, country:GB]; RCVD_TLS_LAST(0.00)[]; MAILMAN_DEST(0.00)[freebsd-fs]; RCVD_IN_DNSWL_LOW(-0.10)[85.119.248.222:from] X-BeenThere: freebsd-fs@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Filesystems List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 02 May 2021 09:57:52 -0000 Hi Rick, On Thursday, April 29, 2021 14:39:10 +0000 Rick Macklem wrote: > N.J. Mann wrote: >> I recently changed over from using svn to gitup to update /usr/ports >> on my local system and have been experiencing problems since. At first >> either a kernel issue or a configuration issue. I originally posted >> about the problem to the freebsd-ports mailing list: >> https://lists.freebsd.org/pipermail/freebsd-ports/2021-April/120929.html >> >> Since then I have dug deeper and come to the conclusion that it is not a >> problem with gitup. >> >> The issue I am seeing is that gitup is unable to delete files and >> directories, even complete ports, which have been removed from the >> repository. gitup basically does the following: >> >> prune_tree(base_path) >> { >> if ((directory = opendir(base_path)) != NULL) { >> while ((entry = readdir(directory)) != NULL) { >> snprintf(full_path, sizeof(full_path), "%s/%s", base_path, entry->d_name); >> if (entry->d_type == DT_DIR) { >> prune_tree(full_path); >> } else { >> if ((remove(full_path) != 0) && (errno != ENOENT)) >> err(EXIT_FAILURE, "prune_tree: cannot remove %s", full_path); >> } >> } >> closedir(directory); >> if (rmdir(base_path) != 0) >> err(EXIT_FAILURE, "prune_tree: cannot remove %s", base_path); >> } >> } > > The code should check for d_type == DT_UNKNOWN and then do > stat() to find out the type, as Ronald noted. > --> The d_type is normally filled in if you use the "rdirplus" > NFS mount option, which might work around the issue. I tried adding "rdirplus" and indeed that fixes the issue. I was unaware of "rdirplus" since somehow I neglected to read the mount_nfs man page. :-( I always say you never stop learning. :-) I have made and tested a new patch for gitup which replaces the use of d_type with a call to stat(). It works fine in my setup without "rdirplus" set and so I think it is the best way forward. I will pass it on to the author of gitup and see what he says. Thanks for the help. Regards, Nick. --