linux-nfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Chuck Lever <chuck.lever@oracle.com>
To: Steve Dickson <steved@redhat.com>
Cc: Linux NFS Mailing List <linux-nfs@vger.kernel.org>
Subject: Re: [PATCH 2/2] mount.nfs: silently fails when the network protocol is not found
Date: Thu, 03 Jun 2010 10:13:58 -0400	[thread overview]
Message-ID: <4C07B8A6.3020803@oracle.com> (raw)
In-Reply-To: <1275570134-24864-3-git-send-email-steved@redhat.com>

On 06/ 3/10 09:02 AM, Steve Dickson wrote:
> mount.nfs should display some type of error diagnostics when
> the network protocol can not be determined.
>
> Signed-off-by: Steve Dickson<steved@redhat.com>
> ---
>   utils/mount/network.c |   19 ++++++++++++++++---
>   utils/mount/stropts.c |   16 +++++++++++-----
>   2 files changed, 27 insertions(+), 8 deletions(-)
>
> diff --git a/utils/mount/network.c b/utils/mount/network.c
> index d9903ed..ffb18ab 100644
> --- a/utils/mount/network.c
> +++ b/utils/mount/network.c
> @@ -1311,6 +1311,8 @@ nfs_nfs_protocol(struct mount_options *options, unsigned long *protocol)
>   		if (option != NULL) {
>   			if (!nfs_get_proto(option,&family, protocol)) {
>   				errno = EPROTONOSUPPORT;
> +				nfs_error(_("%s: Failed to find '%s' protocol"),
> +					progname, option);

Set the errno _after_ calling nfs_error(), which could set it to 
something else.  nfs_error() does call C library functions which may 
alter errno, after all.

>   				return 0;
>   			}
>   			return 1;
> @@ -1399,8 +1401,13 @@ int nfs_nfs_proto_family(struct mount_options *options,
>   	case 2: /* proto */
>   		option = po_get(options, "proto");
>   		if (option != NULL&&
> -		    !nfs_get_proto(option,&tmp_family,&protocol))
> -			goto out_err;
> +		    !nfs_get_proto(option,&tmp_family,&protocol)) {
> +
> +			nfs_error(_("%s: Failed to find '%s' protocol"),
> +				progname, option);
> +			errno = EPROTONOSUPPORT;
> +			return 0;
> +		}
>   	}
>
>   	if (!nfs_verify_family(tmp_family))
> @@ -1492,6 +1499,8 @@ nfs_mount_protocol(struct mount_options *options, unsigned long *protocol)
>   	if (option != NULL) {
>   		if (!nfs_get_proto(option,&family, protocol)) {
>   			errno = EPROTONOSUPPORT;
> +			nfs_error(_("%s: Failed to find '%s' protocol"),
> +				progname, option);

Ditto.

>   			return 0;
>   		}
>   		return 1;
> @@ -1551,8 +1560,12 @@ int nfs_mount_proto_family(struct mount_options *options,
>
>   	option = po_get(options, "mountproto");
>   	if (option != NULL) {
> -		if (!nfs_get_proto(option,&tmp_family,&protocol))
> +		if (!nfs_get_proto(option,&tmp_family,&protocol)) {
> +			nfs_error(_("%s: Failed to find '%s' protocol"),
> +				progname, option);
> +			errno = EPROTONOSUPPORT;
>   			goto out_err;
> +		}

Does out_err also clobber errno here as well?

>   		if (!nfs_verify_family(tmp_family))
>   			goto out_err;
>   		*family = tmp_family;
> diff --git a/utils/mount/stropts.c b/utils/mount/stropts.c
> index 98557d2..0241400 100644
> --- a/utils/mount/stropts.c
> +++ b/utils/mount/stropts.c
> @@ -538,7 +538,10 @@ nfs_rewrite_pmap_mount_options(struct mount_options *options)
>
>   	if (!nfs_construct_new_options(options, nfs_saddr,&nfs_pmap,
>   					mnt_saddr,&mnt_pmap)) {
> -		errno = EINVAL;
> +		if (rpc_createerr.cf_stat == RPC_UNKNOWNPROTO)
> +			errno = EPROTONOSUPPORT;
> +		else
> +			errno = EINVAL;
>   		return 0;
>   	}
>
> @@ -586,18 +589,21 @@ static int nfs_do_mount_v3v2(struct nfsmount_info *mi,
>   		errno = ENOMEM;
>   		return result;
>   	}
> -
> +	errno = 0;
>   	if (!nfs_append_addr_option(sap, salen, options)) {
> -		errno = EINVAL;
> +		if (errno == 0)
> +			errno = EINVAL;
>   		goto out_fail;

What I meant before is that the errno should really be set right where 
the error is detected, not long afterwards in some other part of the code.

Currently it looks like nfs_append_addr_option() sets the errno 
sometimes, and sometimes it doesn't and the errno is set here.  I think 
the code would make more sense overall if the errno was always 
appropriately set by the time nfs_append_addr_option() returns.

Likewise for nfs_construct_new_options() above.

>   	}
>
>   	if (!nfs_fix_mounthost_option(options, mi->hostname)) {
> -		errno = EINVAL;
> +		if (errno == 0)
> +			errno = EINVAL;
>   		goto out_fail;
>   	}
>   	if (!mi->fake&&  !nfs_verify_lock_option(options)) {
> -		errno = EINVAL;
> +		if (errno == 0)
> +			errno = EINVAL;
>   		goto out_fail;
>   	}
>

Likewise for these two.

  reply	other threads:[~2010-06-03 14:15 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-06-03 13:02 [PATCH 0/2] mountd.nfs: Better error diagnostics for the mount command (take 2) Steve Dickson
2010-06-03 13:02 ` [PATCH 1/2] mount: silently fails when bad option values are given Steve Dickson
2010-06-03 14:04   ` Chuck Lever
2010-06-03 14:36     ` Steve Dickson
     [not found]       ` <4C07BE09.3060602-AfCzQyP5zfLQT0dZR+AlfA@public.gmane.org>
2010-06-03 15:55         ` Chuck Lever
2010-06-03 16:32           ` Steve Dickson
     [not found]             ` <4C07D922.7030302-AfCzQyP5zfLQT0dZR+AlfA@public.gmane.org>
2010-06-03 17:38               ` Chuck Lever
2010-06-03 18:18                 ` Steve Dickson
2010-06-03 13:02 ` [PATCH 2/2] mount.nfs: silently fails when the network protocol is not found Steve Dickson
2010-06-03 14:13   ` Chuck Lever [this message]
2010-06-03 16:42     ` Steve Dickson
  -- strict thread matches above, loose matches on Subject: below --
2010-06-03 16:51 [PATCH 0/2] mountd.nfs: Better error diagnostics for the mount command (take 3) Steve Dickson
2010-06-03 16:51 ` [PATCH 2/2] mount.nfs: silently fails when the network protocol is not found Steve Dickson
2010-06-02 13:41 [PATCH 0/2] mountd.nfs: Better error diagnostics for the mount command Steve Dickson
2010-06-02 13:41 ` [PATCH 2/2] mount.nfs: silently fails when the network protocol is not found Steve Dickson
2010-06-02 21:34   ` Chuck Lever
2010-06-03 12:52     ` Steve Dickson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4C07B8A6.3020803@oracle.com \
    --to=chuck.lever@oracle.com \
    --cc=linux-nfs@vger.kernel.org \
    --cc=steved@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).