Skip to contentSkip to conversation

mount.nfs: strip of extra slashes in device name

PATCH In review Steve Dickson 2 participants 5 messages Mar 2, 2012

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mount.nfs: strip of extra slashes in device name

The kernel strips off extra '/' when the device is entered into /proc/mounts. So that umounts can this devices, strip off any extra '/' before storing the device in the mtab.

---
 utils/mount/mount.c |   18 ++++++++++++++++++
 1 files changed, 18 insertions(+), 0 deletions(-)
utils/mount/mount.c +18 -0
index eea00af..eb63f50 100644
@@ -485,6 +485,24 @@ int main(int argc, char *argv[])
 		goto out;
 	}
 	/*
+	 * The kernel strips off extra '/' when the device is entered 
+	 * into /proc/mounts. So that umounts can this devices, strip off
+	 * any extra '/' before storing the device in the mtab.
+	 */
+	if (strstr(spec, "//") != NULL) {
+		char *colen, *slash;
+
+		if ((colen = strchr(spec, ':'))) {
+			slash = (colen + 1);
+			while (*slash && *(slash+1) == '/')
+				slash++;
+			while (*slash)
+				*(++colen) = *(slash++);
+			*(colen+1) = '\0';
+		}
+	}
+
+	/*
 	 * Concatenate mount options from the configuration file
 	 */
 	mount_opts = mount_config_opts(spec, mount_point, mount_opts);
Signature · 1 line
1.7.1
#1 lore raw

My kernel doesn't seem to strip '/' from its /proc/mounts. What kernel are you using? Anyway, how about something similar to the following patch that fixes only NFSv4 atm:

http://www.spinics.net/lists/linux-nfs/msg27351.html

Regards, Malahal.

Quoted 46 lines · Steve Dickson [[email protected]] wrote:

The kernel strips off extra '/' when the device is entered into /proc/mounts. So that umounts can this devices, strip off any extra '/' before storing the device in the mtab.

---
 utils/mount/mount.c |   18 ++++++++++++++++++
 1 files changed, 18 insertions(+), 0 deletions(-)
utils/mount/mount.c +18 -0
index eea00af..eb63f50 100644
@@ -485,6 +485,24 @@ int main(int argc, char *argv[])
 		goto out;
 	}
 	/*
+	 * The kernel strips off extra '/' when the device is entered 
+	 * into /proc/mounts. So that umounts can this devices, strip off
+	 * any extra '/' before storing the device in the mtab.
+	 */
+	if (strstr(spec, "//") != NULL) {
+		char *colen, *slash;
+
+		if ((colen = strchr(spec, ':'))) {
+			slash = (colen + 1);
+			while (*slash && *(slash+1) == '/')
+				slash++;
+			while (*slash)
+				*(++colen) = *(slash++);
+			*(colen+1) = '\0';
+		}
+	}
+
+	/*
 	 * Concatenate mount options from the configuration file
 	 */
 	mount_opts = mount_config_opts(spec, mount_point, mount_opts);
Signature · 6 lines
1.7.1

--
To unsubscribe from this list: send the line "unsubscribe linux-nfs" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#2 lore raw
Quoted 2 lines · Malahal Naineni

My kernel doesn't seem to strip '/' from its /proc/mounts. What kernel are you using?

a later RHEL6 kernel... but I see the same thing with Fedora f16 kernels (3.2) as well... What kernel are you using?

Quoted 4 lines

Anyway, how about something similar to the following patch that fixes only NFSv4 atm:

http://www.spinics.net/lists/linux-nfs/msg27351.html

I made a comment on that... Again, sorry for my tartness...

steved.

Quoted 55 lines

Regards, Malahal.

Quoted 46 lines · Steve Dickson [[email protected]] wrote:

The kernel strips off extra '/' when the device is entered into /proc/mounts. So that umounts can this devices, strip off any extra '/' before storing the device in the mtab.

---
 utils/mount/mount.c |   18 ++++++++++++++++++
 1 files changed, 18 insertions(+), 0 deletions(-)
utils/mount/mount.c +18 -0
index eea00af..eb63f50 100644
@@ -485,6 +485,24 @@ int main(int argc, char *argv[])
 		goto out;
 	}
 	/*
+	 * The kernel strips off extra '/' when the device is entered 
+	 * into /proc/mounts. So that umounts can this devices, strip off
+	 * any extra '/' before storing the device in the mtab.
+	 */
+	if (strstr(spec, "//") != NULL) {
+		char *colen, *slash;
+
+		if ((colen = strchr(spec, ':'))) {
+			slash = (colen + 1);
+			while (*slash && *(slash+1) == '/')
+				slash++;
+			while (*slash)
+				*(++colen) = *(slash++);
+			*(colen+1) = '\0';
+		}
+	}
+
+	/*
 	 * Concatenate mount options from the configuration file
 	 */
 	mount_opts = mount_config_opts(spec, mount_point, mount_opts);
Signature · 6 lines
1.7.1

--
To unsubscribe from this list: send the line "unsubscribe linux-nfs" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

--
To unsubscribe from this list: send the line "unsubscribe linux-nfs" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#3 lore raw
Quoted 7 lines · Steve Dickson [[email protected]] wrote:
Quoted 2 lines · Malahal Naineni

My kernel doesn't seem to strip '/' from its /proc/mounts. What kernel are you using?

a later RHEL6 kernel... but I see the same thing with Fedora f16 kernels (3.2) as well... What kernel are you using?

Using 3.3.0-rc1+ kernel.
[root@elm3c105 ~]# grep mnt /proc/mounts
elm3c104:///server/ /mnt nfs rw,relatime,vers=3,rsize=1048576,wsize=1048576,namlen=255,hard,proto=tcp,timeo=600,retrans=2,sec=sys,mountaddr=9.47.69.104,mountvers=3,mountport=929,mountproto=udp,local_lock=none,addr=9.47.69.104 0 0

I must be missing something, I see the same thing in RHEL6.2 version of Linux.

Regards, Malahal.

#4 lore raw
Quoted 8 lines · Malahal Naineni [[email protected]] wrote:
Quoted 1 line

as well... What kernel are you using?

Using 3.3.0-rc1+ kernel.
[root@elm3c105 ~]# grep mnt /proc/mounts
elm3c104:///server/ /mnt nfs rw,relatime,vers=3,rsize=1048576,wsize=1048576,namlen=255,hard,proto=tcp,timeo=600,retrans=2,sec=sys,mountaddr=9.47.69.104,mountvers=3,mountport=929,mountproto=udp,local_lock=none,addr=9.47.69.104 0 0

I must be missing something, I see the same thing in RHEL6.2 version of Linux.

I rebooted my server with an older distro and you can see above that it is mounting NFSv3. Sorry, my bad. Kernel does strip extra leading '/'s when I mount NFSv4.

Regards, Malahal.