]> git.saurik.com Git - apple/xnu.git/blobdiff - bsd/nfs/krpc_subr.c
xnu-2422.90.20.tar.gz
[apple/xnu.git] / bsd / nfs / krpc_subr.c
index f342ae47611d6e49a5f065a384b0325d47499447..8ded0f04bedf7c0710560d98df1b34a2d6f8d1d8 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000-2004 Apple Computer, Inc. All rights reserved.
+ * Copyright (c) 2000-2008 Apple Inc. All rights reserved.
  *
  * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
  * 
@@ -76,7 +76,6 @@
 #include <sys/socketvar.h>
 #include <sys/systm.h>
 #include <sys/reboot.h>
-#include <sys/uio_internal.h>
 
 #include <net/if.h>
 #include <netinet/in.h>
@@ -216,10 +215,11 @@ krpc_call(sa, sotype, prog, vers, func, data, from_p)
        mbuf_t m, nam, mhead;
        struct rpc_call *call;
        struct rpc_reply *reply;
-       int error, timo, secs, len;
+       int error, timo, secs;
+       size_t len;
        static u_int32_t xid = ~0xFF;
        u_int16_t tport;
-       int maxpacket = 1<<16;
+       size_t maxpacket = 1<<16;
 
        /*
         * Validate address family.
@@ -235,7 +235,7 @@ krpc_call(sa, sotype, prog, vers, func, data, from_p)
         * Create socket and set its recieve timeout.
         */
        if ((error = sock_socket(AF_INET, sotype, 0, 0, 0, &so)))
-               goto out;
+               goto out1;
 
        {
                struct timeval tv;
@@ -335,7 +335,7 @@ krpc_call(sa, sotype, prog, vers, func, data, from_p)
         */
        if (sotype == SOCK_STREAM) {
                /* first, fill in RPC record marker */
-               u_long *recmark = mbuf_data(mhead);
+               u_int32_t *recmark = mbuf_data(mhead);
                *recmark = htonl(0x80000000 | (mbuf_pkthdr_len(mhead) - 4));
                call = (struct rpc_call *)(recmark + 1);
        } else {
@@ -400,11 +400,11 @@ krpc_call(sa, sotype, prog, vers, func, data, from_p)
                        }
                        if (sotype == SOCK_STREAM) {
                                int maxretries = 60;
-                               struct iovec_32 aio;
-                               aio.iov_base = (uintptr_t) &len;
-                               aio.iov_len = sizeof(u_long);
+                               struct iovec aio;
+                               aio.iov_base = &len;
+                               aio.iov_len = sizeof(u_int32_t);
                                bzero(&msg, sizeof(msg));
-                               msg.msg_iov = (struct iovec *) &aio;
+                               msg.msg_iov = &aio;
                                msg.msg_iovlen = 1;
                                do {
                                   error = sock_receive(so, &msg, MSG_WAITALL, &readlen);
@@ -414,8 +414,8 @@ krpc_call(sa, sotype, prog, vers, func, data, from_p)
                                if (!error && readlen < aio.iov_len) {
                                    /* only log a message if we got a partial word */
                                    if (readlen != 0)
-                                           printf("short receive (%d/%d) from server " IP_FORMAT "\n",
-                                                readlen, sizeof(u_long), IP_LIST(&(sin->sin_addr.s_addr)));
+                                           printf("short receive (%ld/%ld) from server " IP_FORMAT "\n",
+                                                readlen, sizeof(u_int32_t), IP_LIST(&(sin->sin_addr.s_addr)));
                                    error = EPIPE;
                                }
                                if (error)
@@ -426,7 +426,7 @@ krpc_call(sa, sotype, prog, vers, func, data, from_p)
                                 * and forcing a disconnect/reconnect is all I can do.
                                 */
                                if (len > maxpacket) {
-                                   printf("impossible packet length (%d) from server %s\n",
+                                   printf("impossible packet length (%ld) from server " IP_FORMAT "\n",
                                        len, IP_LIST(&(sin->sin_addr.s_addr)));
                                    error = EFBIG;
                                    goto out;
@@ -437,8 +437,8 @@ krpc_call(sa, sotype, prog, vers, func, data, from_p)
                                    error = sock_receivembuf(so, NULL, &m, MSG_WAITALL, &readlen);
                                } while (error == EWOULDBLOCK);
 
-                               if (!error && (len > (int)readlen)) {
-                                   printf("short receive (%d/%d) from server %s\n",
+                               if (!error && (len > readlen)) {
+                                   printf("short receive (%ld/%ld) from server " IP_FORMAT "\n",
                                        readlen, len, IP_LIST(&(sin->sin_addr.s_addr)));
                                    error = EPIPE;
                                }
@@ -556,8 +556,9 @@ krpc_call(sa, sotype, prog, vers, func, data, from_p)
        /* result */
        *data = m;
  out:
+       sock_close(so);
+out1:
        if (nam) mbuf_freem(nam);
        if (mhead) mbuf_freem(mhead);
-       sock_close(so);
        return error;
 }