Date: Sun, 02 May 2021 10:57:47 +0100 From: "N.J. Mann" <njm@njm.me.uk> To: Rick Macklem <rmacklem@uoguelph.ca> 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: <YQXPR0101MB096836625A188C6751B3F5E6DD5F9@YQXPR0101MB0968.CANPRD01.PROD.OUTLOOK.COM> References: <2E84A420CCC10A73504624DE@triton.njm.me.uk> <YQXPR0101MB096836625A188C6751B3F5E6DD5F9@YQXPR0101MB0968.CANPRD01.PROD.OUTLOOK.COM>
next in thread | previous in thread | raw e-mail | index | archive | help
Hi Rick, On Thursday, April 29, 2021 14:39:10 +0000 Rick Macklem <rmacklem@uoguelph.ca> 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. --
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?362D4A23EABEC786267883FF>