]> git.decadent.org.uk Git - nfs-utils.git/blobdiff - utils/mount/network.c
mount: Set protocol family properly for "udp" and "tcp"
[nfs-utils.git] / utils / mount / network.c
index a12fbe23ef9f779f29fc03f30abf2fc48be40332..8dc183a16e78983ef8fcf8f79506275b1c635763 100644 (file)
@@ -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,
 
 /*
  * 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)
  */
 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");
                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;
+               }
        }
 
        /*
        }
 
        /*
@@ -1367,8 +1373,9 @@ int nfs_nfs_proto_family(struct mount_options *options,
 
        switch (po_rightmost(options, nfs_transport_opttbl)) {
        case 0: /* udp */
 
        switch (po_rightmost(options, nfs_transport_opttbl)) {
        case 0: /* udp */
-               return 1;
        case 1: /* tcp */
        case 1: /* tcp */
+               /* for compatibility; these are always AF_INET */
+               *family = AF_INET;
                return 1;
        case 2: /* proto */
                option = po_get(options, "proto");
                return 1;
        case 2: /* proto */
                option = po_get(options, "proto");
@@ -1449,7 +1456,8 @@ nfs_mount_version(struct mount_options *options, unsigned long *version)
 
 /*
  * Returns TRUE if @protocol contains a valid value for this option,
 
 /*
  * 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)
  */
 static int
 nfs_mount_protocol(struct mount_options *options, unsigned long *protocol)
@@ -1458,8 +1466,13 @@ nfs_mount_protocol(struct mount_options *options, unsigned long *protocol)
        char *option;
 
        option = po_get(options, "mountproto");
        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
 
        /*
         * MNT transport protocol wasn't specified.  If the NFS