diff mbox

nfsdcltrack: skip "." and ".." when trying to clean out legacy recdir

Message ID 1352753698-17693-1-git-send-email-jlayton@redhat.com (mailing list archive)
State New, archived
Headers show

Commit Message

Jeff Layton Nov. 12, 2012, 8:54 p.m. UTC
readdir picks up these two entries as "normal" dentries, but rmdir'ing
them won't work (and we wouldn't want to remove them anyway).

Signed-off-by: Jeff Layton <jlayton@redhat.com>
---
 utils/nfsdcltrack/nfsdcltrack.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

Comments

Steve Dickson Nov. 28, 2012, 7:53 p.m. UTC | #1
On 12/11/12 15:54, Jeff Layton wrote:
> readdir picks up these two entries as "normal" dentries, but rmdir'ing
> them won't work (and we wouldn't want to remove them anyway).
> 
> Signed-off-by: Jeff Layton <jlayton@redhat.com>
Committed...

steved.
> ---
>  utils/nfsdcltrack/nfsdcltrack.c | 11 +++++++++++
>  1 file changed, 11 insertions(+)
> 
> diff --git a/utils/nfsdcltrack/nfsdcltrack.c b/utils/nfsdcltrack/nfsdcltrack.c
> index 9801b9c..4334340 100644
> --- a/utils/nfsdcltrack/nfsdcltrack.c
> +++ b/utils/nfsdcltrack/nfsdcltrack.c
> @@ -379,6 +379,17 @@ cltrack_legacy_gracedone(void)
>  	while ((entry = readdir(v4recovery))) {
>  		int len;
>  
> +		/* skip "." and ".." */
> +		if (entry->d_name[0] == '.') {
> +			switch (entry->d_name[1]) {
> +			case '\0':
> +				continue;
> +			case '.':
> +				if (entry->d_name[2] == '\0')
> +					continue;
> +			}
> +		}
> +
>  		/* borrow the clientid blob for this */
>  		len = snprintf((char *)blob, sizeof(blob), "%s/%s", dirname,
>  				entry->d_name);
> 
--
To unsubscribe from this list: send the line "unsubscribe linux-nfs" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/utils/nfsdcltrack/nfsdcltrack.c b/utils/nfsdcltrack/nfsdcltrack.c
index 9801b9c..4334340 100644
--- a/utils/nfsdcltrack/nfsdcltrack.c
+++ b/utils/nfsdcltrack/nfsdcltrack.c
@@ -379,6 +379,17 @@  cltrack_legacy_gracedone(void)
 	while ((entry = readdir(v4recovery))) {
 		int len;
 
+		/* skip "." and ".." */
+		if (entry->d_name[0] == '.') {
+			switch (entry->d_name[1]) {
+			case '\0':
+				continue;
+			case '.':
+				if (entry->d_name[2] == '\0')
+					continue;
+			}
+		}
+
 		/* borrow the clientid blob for this */
 		len = snprintf((char *)blob, sizeof(blob), "%s/%s", dirname,
 				entry->d_name);