diff mbox series

Fix error reporting for already mounted shares.

Message ID YfvV6O+accmE0yVb@fedora.rsable.com (mailing list archive)
State New, archived
Headers show
Series Fix error reporting for already mounted shares. | expand

Commit Message

Rohan Sable Feb. 3, 2022, 1:17 p.m. UTC
When mount is triggered for an already mounted
share (using auto negotiation), it displays
"mount.nfs: Protocol not supported" or
"mount.nfs: access denied by server while mounting"
instead of EBUSY. This easily causes confusion if
the mount was not tried verbose :

[root@rsable ~]# mount 127.0.0.1:/export /mnt
mount.nfs: Protocol not supported

[root@rsable ~]# mount -v 127.0.0.1:/export /mnt
mount.nfs: timeout set for Mon Apr  5 16:03:53 2021
mount.nfs: trying text-based options 'vers=4.2,addr=127.0.0.1,clientaddr=127.0.0.1'
mount.nfs: mount(2): Protocol not supported
mount.nfs: trying text-based options 'vers=4,minorversion=1,addr=127.0.0.1,clientaddr=127.0.0.1'
mount.nfs: mount(2): Protocol not supported
mount.nfs: trying text-based options 'vers=4,addr=127.0.0.1,clientaddr=127.0.0.1'
mount.nfs: mount(2): Protocol not supported
mount.nfs: trying text-based options 'addr=127.0.0.1'
mount.nfs: prog 100003, trying vers=3, prot=6
mount.nfs: trying 127.0.0.1 prog 100003 vers 3 prot TCP port 2049
mount.nfs: prog 100005, trying vers=3, prot=17
mount.nfs: trying 127.0.0.1 prog 100005 vers 3 prot UDP port 20048
mount.nfs: mount(2): Device or resource busy  << actual error
mount.nfs: Protocol not supported

[root@rsable ~]# mount rsable76server:/testshare /mnt
mount.nfs: access denied by server while mounting rsable76server:/testshare

[root@rsable ~]# mount rsable76server:/testshare /mnt -v
mount.nfs: timeout set for Mon Jan 17 13:36:16 2022
mount.nfs: trying text-based options 'vers=4.1,addr=192.168.122.58,clientaddr=192.168.122.82'
mount.nfs: mount(2): Permission denied
mount.nfs: trying text-based options 'vers=4.0,addr=192.168.122.58,clientaddr=192.168.122.82'
mount.nfs: mount(2): Permission denied
mount.nfs: trying text-based options 'addr=192.168.122.58'
mount.nfs: prog 100003, trying vers=3, prot=6
mount.nfs: trying 192.168.122.58 prog 100003 vers 3 prot TCP port 2049
mount.nfs: prog 100005, trying vers=3, prot=17
mount.nfs: trying 192.168.122.58 prog 100005 vers 3 prot UDP port 20048
mount.nfs: mount(2): Device or resource busy	<< actual error
mount.nfs: access denied by server while mounting rsable76server:/testshare

Signed-off-by: Rohan Sable <rsable@redhat.com>
Signed-off-by: Yongcheng Yang <yoyang@redhat.com>
---
 utils/mount/stropts.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

Comments

Steve Dickson Feb. 14, 2022, 4:20 p.m. UTC | #1
On 2/3/22 8:17 AM, Rohan Sable wrote:
> When mount is triggered for an already mounted
> share (using auto negotiation), it displays
> "mount.nfs: Protocol not supported" or
> "mount.nfs: access denied by server while mounting"
> instead of EBUSY. This easily causes confusion if
> the mount was not tried verbose :
> 
> [root@rsable ~]# mount 127.0.0.1:/export /mnt
> mount.nfs: Protocol not supported
> 
> [root@rsable ~]# mount -v 127.0.0.1:/export /mnt
> mount.nfs: timeout set for Mon Apr  5 16:03:53 2021
> mount.nfs: trying text-based options 'vers=4.2,addr=127.0.0.1,clientaddr=127.0.0.1'
> mount.nfs: mount(2): Protocol not supported
> mount.nfs: trying text-based options 'vers=4,minorversion=1,addr=127.0.0.1,clientaddr=127.0.0.1'
> mount.nfs: mount(2): Protocol not supported
> mount.nfs: trying text-based options 'vers=4,addr=127.0.0.1,clientaddr=127.0.0.1'
> mount.nfs: mount(2): Protocol not supported
> mount.nfs: trying text-based options 'addr=127.0.0.1'
> mount.nfs: prog 100003, trying vers=3, prot=6
> mount.nfs: trying 127.0.0.1 prog 100003 vers 3 prot TCP port 2049
> mount.nfs: prog 100005, trying vers=3, prot=17
> mount.nfs: trying 127.0.0.1 prog 100005 vers 3 prot UDP port 20048
> mount.nfs: mount(2): Device or resource busy  << actual error
> mount.nfs: Protocol not supported
> 
> [root@rsable ~]# mount rsable76server:/testshare /mnt
> mount.nfs: access denied by server while mounting rsable76server:/testshare
> 
> [root@rsable ~]# mount rsable76server:/testshare /mnt -v
> mount.nfs: timeout set for Mon Jan 17 13:36:16 2022
> mount.nfs: trying text-based options 'vers=4.1,addr=192.168.122.58,clientaddr=192.168.122.82'
> mount.nfs: mount(2): Permission denied
> mount.nfs: trying text-based options 'vers=4.0,addr=192.168.122.58,clientaddr=192.168.122.82'
> mount.nfs: mount(2): Permission denied
> mount.nfs: trying text-based options 'addr=192.168.122.58'
> mount.nfs: prog 100003, trying vers=3, prot=6
> mount.nfs: trying 192.168.122.58 prog 100003 vers 3 prot TCP port 2049
> mount.nfs: prog 100005, trying vers=3, prot=17
> mount.nfs: trying 192.168.122.58 prog 100005 vers 3 prot UDP port 20048
> mount.nfs: mount(2): Device or resource busy	<< actual error
> mount.nfs: access denied by server while mounting rsable76server:/testshare
> 
> Signed-off-by: Rohan Sable <rsable@redhat.com>
> Signed-off-by: Yongcheng Yang <yoyang@redhat.com>
Committed...

steved.
> ---
>   utils/mount/stropts.c | 4 +++-
>   1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/utils/mount/stropts.c b/utils/mount/stropts.c
> index 3c4e218a..573df6ee 100644
> --- a/utils/mount/stropts.c
> +++ b/utils/mount/stropts.c
> @@ -973,7 +973,9 @@ fall_back:
>   	if ((result = nfs_try_mount_v3v2(mi, FALSE)))
>   		return result;
>   
> -	errno = olderrno;
> +	if (errno != EBUSY || errno != EACCES)
> +		errno = olderrno;
> +
>   	return result;
>   }
>
diff mbox series

Patch

diff --git a/utils/mount/stropts.c b/utils/mount/stropts.c
index 3c4e218a..573df6ee 100644
--- a/utils/mount/stropts.c
+++ b/utils/mount/stropts.c
@@ -973,7 +973,9 @@  fall_back:
 	if ((result = nfs_try_mount_v3v2(mi, FALSE)))
 		return result;
 
-	errno = olderrno;
+	if (errno != EBUSY || errno != EACCES)
+		errno = olderrno;
+
 	return result;
 }