From 33203b53ac5f43eef995c100299e45bd441c67d8 Mon Sep 17 00:00:00 2001 From: Jeff Layton Date: Fri, 12 Feb 2010 14:35:31 -0500 Subject: [PATCH] mount.nfs: make nfs_{nfs,mount}_proto set errno on error Have nfs_nfs_proto and nfs_mount_proto set errno to EPROTONOSUPPORT on error. This helps default_value to display sane warning messages. Signed-off-by: Jeff Layton Reviewed-by: Chuck Lever Signed-off-by: Steve Dickson --- utils/mount/network.c | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/utils/mount/network.c b/utils/mount/network.c index a12fbe2..f020933 100644 --- a/utils/mount/network.c +++ b/utils/mount/network.c @@ -1273,7 +1273,8 @@ nfs_nfs_version(struct mount_options *options, unsigned long *version) /* * Returns TRUE if @protocol contains a valid value for this option, - * or FALSE if the option was specified with an invalid value. + * or FALSE if the option was specified with an invalid value. On + * error, errno is set. */ int nfs_nfs_protocol(struct mount_options *options, unsigned long *protocol) @@ -1290,8 +1291,13 @@ nfs_nfs_protocol(struct mount_options *options, unsigned long *protocol) return 1; case 2: /* proto */ option = po_get(options, "proto"); - if (option != NULL) - return nfs_get_proto(option, &family, protocol); + if (option != NULL) { + if (!nfs_get_proto(option, &family, protocol)) { + errno = EPROTONOSUPPORT; + return 0; + } + return 1; + } } /* @@ -1449,7 +1455,8 @@ nfs_mount_version(struct mount_options *options, unsigned long *version) /* * Returns TRUE if @protocol contains a valid value for this option, - * or FALSE if the option was specified with an invalid value. + * or FALSE if the option was specified with an invalid value. On + * error, errno is set. */ static int nfs_mount_protocol(struct mount_options *options, unsigned long *protocol) @@ -1458,8 +1465,13 @@ nfs_mount_protocol(struct mount_options *options, unsigned long *protocol) char *option; option = po_get(options, "mountproto"); - if (option != NULL) - return nfs_get_proto(option, &family, protocol); + if (option != NULL) { + if (!nfs_get_proto(option, &family, protocol)) { + errno = EPROTONOSUPPORT; + return 0; + } + return 1; + } /* * MNT transport protocol wasn't specified. If the NFS -- 2.39.2