mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Sascha Hauer <s.hauer@pengutronix.de>
To: "Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>
Cc: barebox@lists.infradead.org
Subject: Re: [PATCH] nfs: check return value of various rpc calls
Date: Mon, 2 Nov 2020 10:14:29 +0100	[thread overview]
Message-ID: <20201102091429.GU26805@pengutronix.de> (raw)
In-Reply-To: <20201030113614.9572-1-u.kleine-koenig@pengutronix.de>

On Fri, Oct 30, 2020 at 12:36:14PM +0100, Uwe Kleine-König wrote:
> Check more carefully for failing requests. This improves the error
> message when trying to mount a non-exported nfs directory from:
> 
> 	nfs_mount_req: file handle too big: 44831
> 
> to
> 
> 	nfs_mount_req: Mounting gave error NFS3ERR_ACCES(0xd)
> 
> .
> 
> Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
> ---
>  fs/nfs.c | 91 +++++++++++++++++++++++++++++++++++++++++++++++++-------
>  1 file changed, 81 insertions(+), 10 deletions(-)
> 
> diff --git a/fs/nfs.c b/fs/nfs.c
> index 15ddab7915df..0be32322fb65 100644
> --- a/fs/nfs.c
> +++ b/fs/nfs.c
> @@ -636,13 +636,33 @@ static uint32_t *nfs_read_post_op_attr(uint32_t *p, struct inode *inode)
>  	return p;
>  }
>  
> +static int nfserror_to_err(u32 nfserror, const char **errorname)
> +{
> +#define E(NFSERR, ERR)			\
> +	case NFSERR:			\
> +		*errorname = #NFSERR;	\
> +		return -ERR
> +
> +	switch (nfserror) {
> +	E(NFS3_OK, 0);
> +	E(NFS3ERR_NOENT, ENOENT);
> +	E(NFS3ERR_IO, EIO);
> +	E(NFS3ERR_ACCES, EACCES);
> +	E(NFS3ERR_NOTDIR, ENOTDIR);
> +	E(NFS3ERR_NAMETOOLONG, ENAMETOOLONG);

You convert the NFS error codes to the corresponding error codes. For
these we already have strings, so why not just print them with %pe rather
than returning another string from this function?

Sascha

-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

  reply	other threads:[~2020-11-02  9:14 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-30 11:36 Uwe Kleine-König
2020-11-02  9:14 ` Sascha Hauer [this message]
2020-11-02 13:56   ` Uwe Kleine-König

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=20201102091429.GU26805@pengutronix.de \
    --to=s.hauer@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    --cc=u.kleine-koenig@pengutronix.de \
    /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