Skip to contentSkip to conversation

nfs: use canonical path in nfs_show_devname

PATCH In review Xiong Zhou 3 participants 5 messages Aug 20, 2014 – Aug 25, 2014 1 message not in the archive

Subsystems (2)
lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

Xiong Zhou

author
#1 lore raw

PATCH 1/1 nfs: use canonical path in nfs_show_devname

When export root dir(/) via nfs, and mount a particular dir under root, eg /nfsexport, there will be defect double slash output in /proc/mounts, like localhost://nfsexport.

---
 fs/nfs/super.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/nfs/super.c +1 -1
index e4499d5..62b1cab 100644
@@ -780,7 +780,7 @@ int nfs_show_devname(struct seq_file *m, struct dentry *root)
 	int err = 0;
 	if (!page)
 		return -ENOMEM;
-	devname = nfs_path(&dummy, root, page, PAGE_SIZE, 0);
+	devname = nfs_path(&dummy, root, page, PAGE_SIZE, 1);
 	if (IS_ERR(devname))
 		err = PTR_ERR(devname);
 	else
Signature · 1 line
1.8.3.1
#2 lore raw
Quoted 14 lines · Xiong Zhou

When export root dir(/) via nfs, and mount a particular dir under root, eg /nfsexport, there will be defect double slash output in /proc/mounts, like localhost://nfsexport.

---
 fs/nfs/super.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/nfs/super.c +0 -0
index e4499d5..62b1cab 100644

fs/nfs/super.c int nfs_show_devname(struct seq_file *m, struct dentry *root) · line 786

Quoted 8 lines
fs/nfs/super.c +1 -1
@@ -780,7 +780,7 @@ int nfs_show_devname(struct seq_file *m, struct dentry *root)
 	int err = 0;
 	if (!page)
 		return -ENOMEM;
-	devname = nfs_path(&dummy, root, page, PAGE_SIZE, 0);
+	devname = nfs_path(&dummy, root, page, PAGE_SIZE, 1);
 	if (IS_ERR(devname))
 		err = PTR_ERR(devname);
 	else

This will reintroduce the problem reported in
<https://bugs.debian.org/669314>.

Ben.

Signature · 2 lines
Ben Hutchings
If at first you don't succeed, you're doing about average.
author
#3 lore raw

PATCH v2 1/1 nfs: remove redundant slash from nfs_path

When export root dir(/) via nfs, and mount a particular dir under root, eg /nfsexport, there will be defect double slash output in /proc/mounts, like localhost://nfsexport. While this patch change it to localhost:/nfsexport.

---
 fs/nfs/namespace.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/nfs/namespace.c +1 -1
index b5a0afc..24f954e 100644
@@ -98,7 +98,7 @@ rename_retry:
 		return end;
 	}
 	namelen = strlen(base);
-	if (flags & NFS_PATH_CANONICAL) {
+	if ((flags & NFS_PATH_CANONICAL) || *end == '/') {
 		/* Strip off excess slashes in base string */
 		while (namelen > 0 && base[namelen - 1] == '/')
 			namelen--;
Signature · 1 line
1.8.3.1
#4 lore raw

Re: [PATCH v2] nfs: remove redundant slash from nfs_path

Quoted 14 lines · Xiong Zhou

When export root dir(/) via nfs, and mount a particular dir under root, eg /nfsexport, there will be defect double slash output in /proc/mounts, like localhost://nfsexport. While this patch change it to localhost:/nfsexport.

---
 fs/nfs/namespace.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/nfs/namespace.c +0 -0
index b5a0afc..24f954e 100644

fs/nfs/namespace.c rename_retry: · line 104

Quoted 8 lines
fs/nfs/namespace.c +1 -1
@@ -98,7 +98,7 @@ rename_retry:
 		return end;
 	}
 	namelen = strlen(base);
-	if (flags & NFS_PATH_CANONICAL) {
+	if ((flags & NFS_PATH_CANONICAL) || *end == '/') {
 		/* Strip off excess slashes in base string */
 		while (namelen > 0 && base[namelen - 1] == '/')
 			namelen--;

I think this makes sense, though I'm not sure I completely understand this function. :-/

Ben.

Signature · 2 lines
Ben Hutchings
All extremists should be taken out and shot.
#5 lore raw

Re: [PATCH v2] nfs: remove redundant slash from nfs_path

Quoted 10 lines · Ben Hutchings
Quoted 9 lines · Xiong Zhou

When export root dir(/) via nfs, and mount a particular dir under root, eg /nfsexport, there will be defect double slash output in /proc/mounts, like localhost://nfsexport. While this patch change it to localhost:/nfsexport.

---
 fs/nfs/namespace.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 17 lines

fs/nfs/namespace.c rename_retry: · line 104

Quoted 13 lines
fs/nfs/namespace.c +1 -1
index b5a0afc..24f954e 100644
@@ -98,7 +98,7 @@ rename_retry:
              return end;
      }
      namelen = strlen(base);
-     if (flags & NFS_PATH_CANONICAL) {
+     if ((flags & NFS_PATH_CANONICAL) || *end == '/') {
              /* Strip off excess slashes in base string */
              while (namelen > 0 && base[namelen - 1] == '/')
                      namelen--;

I think this makes sense, though I'm not sure I completely understand this function. :-/

It breaks the function's guarantee concerning NFS_PATH_CANONICAL; that "if unset, the original name is returned verbatim".

Signature · 5 lines
Trond Myklebust

Linux NFS client maintainer, PrimaryData

[email protected]