2014-08-20 03:06:47

by Murphy Zhou

[permalink] [raw]
Subject: [PATCH] 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.

Signed-off-by: Xiong Zhou <[email protected]>
---
fs/nfs/super.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/nfs/super.c b/fs/nfs/super.c
index e4499d5..62b1cab 100644
--- a/fs/nfs/super.c
+++ b/fs/nfs/super.c
@@ -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
--
1.8.3.1



2014-08-25 21:17:31

by Trond Myklebust

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

On Mon, Aug 25, 2014 at 5:07 PM, Ben Hutchings <[email protected]> wrote:
> On Mon, 2014-08-25 at 01:51 -0400, Xiong Zhou wrote:
>> 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.
>>
>> Signed-off-by: Xiong Zhou <[email protected]>
>> ---
>> fs/nfs/namespace.c | 2 +-
>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/fs/nfs/namespace.c b/fs/nfs/namespace.c
>> index b5a0afc..24f954e 100644
>> --- a/fs/nfs/namespace.c
>> +++ b/fs/nfs/namespace.c
>> @@ -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".

--
Trond Myklebust

Linux NFS client maintainer, PrimaryData

[email protected]

2014-08-25 21:07:23

by Ben Hutchings

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

On Mon, 2014-08-25 at 01:51 -0400, Xiong Zhou wrote:
> 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.
>
> Signed-off-by: Xiong Zhou <[email protected]>
> ---
> fs/nfs/namespace.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/fs/nfs/namespace.c b/fs/nfs/namespace.c
> index b5a0afc..24f954e 100644
> --- a/fs/nfs/namespace.c
> +++ b/fs/nfs/namespace.c
> @@ -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.

--
Ben Hutchings
All extremists should be taken out and shot.


Attachments:
signature.asc (811.00 B)
This is a digitally signed message part

2014-08-20 23:10:52

by Ben Hutchings

[permalink] [raw]
Subject: Re: [PATCH] nfs: use canonical path in nfs_show_devname

On Tue, 2014-08-19 at 23:06 -0400, Xiong Zhou wrote:
> 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.
>
> Signed-off-by: Xiong Zhou <[email protected]>
> ---
> fs/nfs/super.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/fs/nfs/super.c b/fs/nfs/super.c
> index e4499d5..62b1cab 100644
> --- a/fs/nfs/super.c
> +++ b/fs/nfs/super.c
> @@ -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.

--
Ben Hutchings
If at first you don't succeed, you're doing about average.


Attachments:
signature.asc (811.00 B)
This is a digitally signed message part

2014-08-25 05:51:10

by Murphy Zhou

[permalink] [raw]
Subject: [PATCH v2] 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.

Signed-off-by: Xiong Zhou <[email protected]>
---
fs/nfs/namespace.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/nfs/namespace.c b/fs/nfs/namespace.c
index b5a0afc..24f954e 100644
--- a/fs/nfs/namespace.c
+++ b/fs/nfs/namespace.c
@@ -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--;
--
1.8.3.1