linux-nfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Check for beginning '/' in the mount path
@ 2012-02-03  1:42 Malahal Naineni
  2012-02-03 11:15 ` Boaz Harrosh
  0 siblings, 1 reply; 27+ messages in thread
From: Malahal Naineni @ 2012-02-03  1:42 UTC (permalink / raw)
  To: linux-nfs

NFSv4 gladly accepts and mounts "hostname:path" instead of
"hostname:/path". This causes mount entry mistmatch between /etc/mtab
and /proc/mounts files. The former will have "hostname:path" but the
latter will have "hostname:/path". This causes umount not work at all.

Signed-off-by: Malahal Naineni <malahal@us.ibm.com>
---
 utils/mount/stropts.c |   22 ++++++++++++++++++++++
 1 files changed, 22 insertions(+), 0 deletions(-)

diff --git a/utils/mount/stropts.c b/utils/mount/stropts.c
index d52e21a..559114d 100644
--- a/utils/mount/stropts.c
+++ b/utils/mount/stropts.c
@@ -571,6 +571,7 @@ static int nfs_sys_mount(struct nfsmount_info *mi, struct mount_options *opts)
 {
 	char *options = NULL;
 	int result;
+	char *dirname;
 
 	if (mi->fake)
 		return 1;
@@ -580,6 +581,27 @@ static int nfs_sys_mount(struct nfsmount_info *mi, struct mount_options *opts)
 		return 0;
 	}
 
+	/*
+	 * Make sure that dirname in the spec starts with '/'. The mount
+	 * works fine in NFSv4 without the '/', but then /etc/mtab and
+	 * /proc/mounts disagree on the actual mount entry causing later
+	 * umount to fail! There is no reason to allow any dirname not
+	 * starting with '/', so fail it here.
+	 *
+	 * Note that for NFSv2 and NFSv3, the mount call itself fails if
+	 * dirname doesn't start with '/'. So this check is only useful
+	 * for NFSv4.
+	 */
+	dirname = strchr(mi->spec, ']');	/* IPv6 address check */
+	if (dirname)
+		dirname = strchr(dirname+1, ':');
+	else
+		dirname = strchr(mi->spec, ':');
+	if (!dirname || *(dirname+1) != '/') {
+		errno = EINVAL;
+		return 0;
+	}
+
 	result = mount(mi->spec, mi->node, mi->type,
 			mi->flags & ~(MS_USER|MS_USERS), options);
 	free(options);
-- 
1.7.8.3


^ permalink raw reply related	[flat|nested] 27+ messages in thread

end of thread, other threads:[~2012-03-05 15:03 UTC | newest]

Thread overview: 27+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-02-03  1:42 [PATCH] Check for beginning '/' in the mount path Malahal Naineni
2012-02-03 11:15 ` Boaz Harrosh
2012-02-03 12:16   ` NeilBrown
2012-02-03 14:29     ` Malahal Naineni
2012-02-05 11:03       ` Boaz Harrosh
2012-02-06 18:11         ` Malahal Naineni
2012-02-07 20:44         ` [PATCH] Get normalized paths for comparing NFS export paths Malahal Naineni
2012-02-16 18:09           ` Malahal Naineni
2012-03-02 19:10           ` Steve Dickson
2012-03-02 19:27             ` Malahal Naineni
2012-03-02 20:57               ` Steve Dickson
2012-03-02 22:01                 ` Malahal Naineni
2012-03-03 17:39                   ` Steve Dickson
2012-03-03 19:12                     ` Myklebust, Trond
2012-03-04 22:31                       ` Steve Dickson
2012-03-04 22:46                         ` Myklebust, Trond
2012-03-04 23:08                           ` Steve Dickson
2012-03-05  4:46                           ` Malahal Naineni
2012-03-05 12:03                             ` Steve Dickson
2012-03-04 22:58                         ` Steve Dickson
2012-03-04 23:26                           ` Myklebust, Trond
2012-03-05  0:03                             ` Steve Dickson
2012-03-05  2:04                               ` Myklebust, Trond
2012-03-05  4:53                                 ` Malahal Naineni
2012-03-05 11:55                                 ` Steve Dickson
2012-03-05 14:47                                   ` Malahal Naineni
2012-03-05 15:03                                     ` Steve Dickson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).