[PATCH] NFSv4 mounts give wrong error message when server denies the mount

Neil Brown neilb at suse.de
Mon May 14 20:29:52 EDT 2007


On Wednesday May 9, SteveD at redhat.com wrote:
> Here is a 'nit' patch that correct the error messages
> on failed v4 mounts. The patch is relative to Neal's
> nfs-utils git tree...

Hi Steve,
 It seems I missed this and since release 1.1.0.  Sorry about that.

But at question: You define chk_mountpoint, but it is never used.

Is there something missing from this patch?

NeilBrown

> 
> 
> steved.
> commit 76694fdc516b7ae22ca6c69103b111d9b37665ae
> Author: Steve Dickson <steved at redhat.com>
> Date:   Wed May 9 14:15:03 2007 -0400
> 
>     When nfs4 mount fail because the exported directory does
>     not exist, the mount command claims the local mount point
>     does not exist which is wrong. This patch fixes that problem
>     as well as  makes the v4 mount failures look like v3/v2 failures.
>     
>     Signed-off-by: Steve Dickson <steved at redhat.com>
> 
> diff --git a/utils/mount/mount.c b/utils/mount/mount.c
> index 52b0d67..4d21d26 100644
> --- a/utils/mount/mount.c
> +++ b/utils/mount/mount.c
> @@ -285,22 +285,49 @@ static void parse_opts (const char *options, int *flags, char **extra_opts)
>  	}
>  }
>  
> -static void mount_error(char *node)
> +static void mount_error(char *mntpnt, char *node)
>  {
>  	switch(errno) {
>  		case ENOTDIR:
> -			fprintf(stderr, "%s: mount point %s is not a directory\n", progname, node);
> +			fprintf(stderr, "%s: mount point %s is not a directory\n", 
> +				progname, mntpnt);
>  			break;
>  		case EBUSY:
> -			fprintf(stderr, "%s: %s is already mounted or busy\n", progname, node);
> +			fprintf(stderr, "%s: %s is already mounted or busy\n", 
> +				progname, mntpnt);
>  			break;
>  		case ENOENT:
> -			fprintf(stderr, "%s: mount point %s does not exist\n", progname, node);
> +			if (node) {
> +				fprintf(stderr, "%s: %s failed, reason given by server: %s\n",
> +					progname, node, strerror(errno));
> +			} else
> +				fprintf(stderr, "%s: mount point %s does not exist\n", 
> +					progname, mntpnt);
>  			break;
>  		default:
>  			fprintf(stderr, "%s: %s\n", progname, strerror(errno));
>  	}
>  }
> +static int chk_mountpoint(mount_point)
> +{
> +	struct stat sb;
> +
> +	if (stat(mount_point, &sb) < 0){
> +		mount_error(mount_point, NULL);
> +		return 1;
> +	}
> +	if (S_ISDIR(sb.st_mode) == 0){
> +		errno = ENOTDIR;
> +		mount_error(mount_point, NULL);
> +		return 1;
> +	}
> +	if (access(mount_point, X_OK) < 0) {
> +		mount_error(mount_point, NULL);
> +		return 1;
> +	}
> +
> +	return 0;
> +}
>  
>  extern u_short getport(
>  	struct sockaddr_in *saddr,
> @@ -538,7 +565,7 @@ int main(int argc, char *argv[])
>  					   mount_opts);
>  
>  		if (mnt_err) {
> -			mount_error(mount_point);
> +			mount_error(mount_point, spec);
>  			exit(EX_FAIL);
>  		}
>  	}


More information about the NFSv4 mailing list