Skip to contentSkip to conversation

mountd: fix next_mnt handling for "/"

PATCH In review NeilBrown 2 participants 2 messages Feb 16, 2015 – Feb 26, 2015

Subsystems (2)
lore
Share & tools
lore

NeilBrown

author
#0 lore raw

PATCH 1/1 mountd: fix next_mnt handling for "/"

If the (exported) path passed to next_mnt() is simply "/", next_mnt() will not report any children, as none start with "/" followed by a '/'.
So make a special case for strlen(p)==1. In that case, return all children.

This gives correct handling if only "/" is exported.

utils/mountd/cache.c +1 -0
index c23d384d24eb..ac36b6d9f21e 100644
@@ -377,6 +377,7 @@ static char *next_mnt(void **v, char *p)
 	} else
 		f = *v;
 	while ((me = getmntent(f)) != NULL &&
+	       l > 1 &&
 	       (strncmp(me->mnt_dir, p, l) != 0 ||
 		me->mnt_dir[l] != '/'))
 		;
#1 lore raw
Quoted 11 lines · NeilBrown

If the (exported) path passed to next_mnt() is simply "/", next_mnt() will not report any children, as none start with "/" followed by a '/'.
So make a special case for strlen(p)==1. In that case, return all children.

This gives correct handling if only "/" is exported.

Committed!

steved.

Quoted 14 lines
utils/mountd/cache.c +1 -0
index c23d384d24eb..ac36b6d9f21e 100644
@@ -377,6 +377,7 @@ static char *next_mnt(void **v, char *p)
 	} else
 		f = *v;
 	while ((me = getmntent(f)) != NULL &&
+	       l > 1 &&
 	       (strncmp(me->mnt_dir, p, l) != 0 ||
 		me->mnt_dir[l] != '/'))
 		;