]>
git.saurik.com Git - apple/xnu.git/blob - bsd/nfs/nfs_boot.c
2 * Copyright (c) 2000-2004 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_OSREFERENCE_HEADER_START@
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. The rights granted to you under the
10 * License may not be used to create, or enable the creation or
11 * redistribution of, unlawful or unlicensed copies of an Apple operating
12 * system, or to circumvent, violate, or enable the circumvention or
13 * violation of, any terms of an Apple operating system software license
16 * Please obtain a copy of the License at
17 * http://www.opensource.apple.com/apsl/ and read it before using this
20 * The Original Code and all software distributed under the License are
21 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
22 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
23 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
24 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
25 * Please see the License for the specific language governing rights and
26 * limitations under the License.
28 * @APPLE_LICENSE_OSREFERENCE_HEADER_END@
30 /* Copyright (c) 1995, 1997 NeXT Computer, Inc. All Rights Reserved */
32 * Copyright (c) 1994 Adam Glass, Gordon Ross
33 * All rights reserved.
35 * This software was developed by the Computer Systems Engineering group
36 * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and
37 * contributed to Berkeley.
39 * Redistribution and use in source and binary forms, with or without
40 * modification, are permitted provided that the following conditions
42 * 1. Redistributions of source code must retain the above copyright
43 * notice, this list of conditions and the following disclaimer.
44 * 2. Redistributions in binary form must reproduce the above copyright
45 * notice, this list of conditions and the following disclaimer in the
46 * documentation and/or other materials provided with the distribution.
47 * 3. All advertising materials mentioning features or use of this software
48 * must display the following acknowledgement:
49 * This product includes software developed by the University of
50 * California, Lawrence Berkeley Laboratory and its contributors.
51 * 4. Neither the name of the University nor the names of its contributors
52 * may be used to endorse or promote products derived from this software
53 * without specific prior written permission.
55 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
56 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
57 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
58 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
59 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
60 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
61 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
62 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
63 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
64 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
68 * 14-March-97 Dieter Siegmund (dieter@next.com)
69 * - Use BOOTP instead of RARP to get the IP address at boot time
71 * 23-May-97 Umesh Vaishampayan (umeshv@apple.com)
72 * - Added the ability to mount "/private" separately.
74 * 30-May-97 Dieter Siegmund (dieter@next.com)
75 * - Clear out the ireq structure before using it to prevent
76 * our sending using a bogus source IP address, we should use
77 * an IP address of all zeroes
78 * - Right after BOOTP, get the correct netmask using AUTONETMASK
79 * 18-Jul-97 Dieter Siegmund (dieter@apple.com)
80 * - we can't restrict the netmask until we have a default route,
81 * removed AUTONETMASK call (ifdef'd out)
82 * 5-Aug-97 Dieter Siegmund (dieter@apple.com)
83 * - use the default route from the bpwhoami call, enabled autonetmask
85 * 19-Feb-1999 Dieter Siegmund (dieter@apple.com)
86 * - use new BOOTP routine to get the subnet mask and router
87 * and stop using SIOCAUTOADDR
88 * - don't bother mounting private separately if it's not
89 * specified or not required because they are substrings of
90 * one another ie. root=host:/A and private=host:/A/private
91 * - allow the root path to be specified in the boot variable
92 * "rp" (AKA "rootpath")
93 * 19-Jul-1999 Dieter Siegmund (dieter@apple.com)
94 * - replaced big automatic arrays with MALLOC'd data
97 #include <sys/param.h>
98 #include <sys/systm.h>
99 #include <sys/kernel.h>
100 #include <sys/conf.h>
101 #include <sys/ioctl.h>
102 #include <sys/proc.h>
103 #include <sys/mount_internal.h>
104 #include <sys/kpi_mbuf.h>
106 #include <sys/malloc.h>
107 #include <sys/socket.h>
110 #include <net/if_dl.h>
111 #include <net/if_types.h>
112 #include <net/route.h>
114 #include <netinet/in.h>
115 #include <netinet/if_ether.h>
117 #include <nfs/rpcv2.h>
118 #include <nfs/nfsproto.h>
120 #include <nfs/nfsdiskless.h>
121 #include <nfs/krpc.h>
123 #include <pexpert/pexpert.h>
127 #include <libkern/libkern.h>
132 int nfs_boot_init(struct nfs_diskless
*nd
, proc_t procp
)
134 panic("nfs_boot_init: no ether");
137 int nfs_boot_getfh(struct nfs_diskless
*nd
, proc_t procp
, int v3
, int sotype
)
139 panic("nfs_boot_getfh: no ether");
145 * Support for NFS diskless booting, specifically getting information
146 * about where to boot from, what pathnames, etc.
148 * This implememtation uses RARP and the bootparam RPC.
149 * We are forced to implement RPC anyway (to get file handles)
150 * so we might as well take advantage of it for bootparam too.
152 * The diskless boot sequence goes as follows:
153 * (1) Use RARP to get our interface address
154 * (2) Use RPC/bootparam/whoami to get our hostname,
155 * our IP address, and the server's IP address.
156 * (3) Use RPC/bootparam/getfile to get the root path
157 * (4) Use RPC/mountd to get the root file handle
158 * (5) Use RPC/bootparam/getfile to get the swap path
159 * (6) Use RPC/mountd to get the swap file handle
161 * (This happens to be the way Sun does it too.)
165 static int bp_whoami(struct sockaddr_in
*bpsin
,
166 struct in_addr
*my_ip
, struct in_addr
*gw_ip
);
167 static int bp_getfile(struct sockaddr_in
*bpsin
, const char *key
,
168 struct sockaddr_in
*mdsin
, char *servname
, char *path
);
171 static int md_mount(struct sockaddr_in
*mdsin
, char *path
, int v3
, int sotype
,
172 u_char
*fhp
, u_long
*fhlenp
);
175 static int get_file_handle(struct nfs_dlmount
*ndmntp
);
178 #define IP_FORMAT "%d.%d.%d.%d"
179 #define IP_CH(ip) ((u_char *)ip)
180 #define IP_LIST(ip) IP_CH(ip)[0],IP_CH(ip)[1],IP_CH(ip)[2],IP_CH(ip)[3]
183 netboot_iaddr(struct in_addr
* iaddr_p
);
186 netboot_rootpath(struct in_addr
* server_ip
,
187 char * name
, int name_len
,
188 char * path
, int path_len
);
191 * Called with an empty nfs_diskless struct to be filled in.
194 nfs_boot_init(struct nfs_diskless
*nd
, __unused proc_t procp
)
196 struct sockaddr_in bp_sin
;
197 boolean_t do_bpwhoami
= TRUE
;
198 boolean_t do_bpgetfile
= TRUE
;
200 struct in_addr my_ip
;
201 struct sockaddr_in
* sin_p
;
203 /* make sure mbuf constants are set up */
207 /* by this point, networking must already have been configured */
208 if (netboot_iaddr(&my_ip
) == FALSE
) {
209 printf("nfs_boot: networking is not initialized\n");
214 /* get the root path information */
215 MALLOC_ZONE(nd
->nd_root
.ndm_path
, char *, MAXPATHLEN
, M_NAMEI
, M_WAITOK
);
216 if (!nd
->nd_root
.ndm_path
) {
217 printf("nfs_boot: can't allocate root path buffer\n");
221 sin_p
= &nd
->nd_root
.ndm_saddr
;
222 bzero((caddr_t
)sin_p
, sizeof(*sin_p
));
223 sin_p
->sin_len
= sizeof(*sin_p
);
224 sin_p
->sin_family
= AF_INET
;
225 if (netboot_rootpath(&sin_p
->sin_addr
, nd
->nd_root
.ndm_host
,
226 sizeof(nd
->nd_root
.ndm_host
),
227 nd
->nd_root
.ndm_path
, MAXPATHLEN
) == TRUE
) {
228 do_bpgetfile
= FALSE
;
231 nd
->nd_private
.ndm_saddr
.sin_addr
.s_addr
= 0;
234 struct in_addr router
;
236 * Get client name and gateway address.
237 * RPC: bootparam/whoami
238 * Use the old broadcast address for the WHOAMI
239 * call because we do not yet know our netmask.
240 * The server address returned by the WHOAMI call
241 * is used for all subsequent booptaram RPCs.
243 bzero((caddr_t
)&bp_sin
, sizeof(bp_sin
));
244 bp_sin
.sin_len
= sizeof(bp_sin
);
245 bp_sin
.sin_family
= AF_INET
;
246 bp_sin
.sin_addr
.s_addr
= INADDR_BROADCAST
;
247 hostnamelen
= MAXHOSTNAMELEN
;
249 error
= bp_whoami(&bp_sin
, &my_ip
, &router
);
251 printf("nfs_boot: bootparam whoami, error=%d", error
);
254 printf("nfs_boot: BOOTPARAMS server " IP_FORMAT
"\n",
255 IP_LIST(&bp_sin
.sin_addr
));
256 printf("nfs_boot: hostname %s\n", hostname
);
259 error
= bp_getfile(&bp_sin
, "root", &nd
->nd_root
.ndm_saddr
,
260 nd
->nd_root
.ndm_host
, nd
->nd_root
.ndm_path
);
262 printf("nfs_boot: bootparam get root: %d\n", error
);
267 #if !defined(NO_MOUNT_PRIVATE)
268 if (do_bpgetfile
) { /* get private path */
269 MALLOC_ZONE(nd
->nd_private
.ndm_path
, char *, MAXPATHLEN
, M_NAMEI
, M_WAITOK
);
270 if (!nd
->nd_private
.ndm_path
) {
271 printf("nfs_boot: can't allocate private path buffer\n");
275 error
= bp_getfile(&bp_sin
, "private",
276 &nd
->nd_private
.ndm_saddr
,
277 nd
->nd_private
.ndm_host
,
278 nd
->nd_private
.ndm_path
);
280 char * check_path
= NULL
;
282 MALLOC_ZONE(check_path
, char *, MAXPATHLEN
, M_NAMEI
, M_WAITOK
);
284 printf("nfs_boot: can't allocate check_path buffer\n");
288 snprintf(check_path
, MAXPATHLEN
, "%s/private", nd
->nd_root
.ndm_path
);
289 if ((nd
->nd_root
.ndm_saddr
.sin_addr
.s_addr
290 == nd
->nd_private
.ndm_saddr
.sin_addr
.s_addr
)
291 && (strcmp(check_path
, nd
->nd_private
.ndm_path
) == 0)) {
292 /* private path is prefix of root path, don't mount */
293 nd
->nd_private
.ndm_saddr
.sin_addr
.s_addr
= 0;
295 FREE_ZONE(check_path
, MAXPATHLEN
, M_NAMEI
);
298 /* private key not defined, don't mount */
299 nd
->nd_private
.ndm_saddr
.sin_addr
.s_addr
= 0;
305 #endif /* NO_MOUNT_PRIVATE */
311 * Called with a partially initialized nfs_diskless struct
312 * with file handles to be filled in.
315 nfs_boot_getfh(struct nfs_diskless
*nd
, __unused proc_t procp
, int v3
, int sotype
)
319 nd
->nd_root
.ndm_nfsv3
= v3
;
320 nd
->nd_root
.ndm_sotype
= sotype
;
321 error
= get_file_handle(&nd
->nd_root
);
323 printf("nfs_boot: get_file_handle(v%d) root failed, %d\n",
328 #if !defined(NO_MOUNT_PRIVATE)
329 if (nd
->nd_private
.ndm_saddr
.sin_addr
.s_addr
) {
330 /* get private file handle */
331 nd
->nd_private
.ndm_nfsv3
= v3
;
332 nd
->nd_private
.ndm_sotype
= sotype
;
333 error
= get_file_handle(&nd
->nd_private
);
335 printf("nfs_boot: get_file_handle(v%d) private failed, %d\n",
340 #endif /* NO_MOUNT_PRIVATE */
346 get_file_handle(ndmntp
)
347 struct nfs_dlmount
*ndmntp
;
349 char *sp
, *dp
, *endp
;
353 * Get file handle for "key" (root or swap)
354 * using RPC to mountd/mount
356 error
= md_mount(&ndmntp
->ndm_saddr
, ndmntp
->ndm_path
, ndmntp
->ndm_nfsv3
,
357 ndmntp
->ndm_sotype
, ndmntp
->ndm_fh
, &ndmntp
->ndm_fhlen
);
361 /* Construct remote path (for getmntinfo(3)) */
362 dp
= ndmntp
->ndm_host
;
363 endp
= dp
+ MNAMELEN
- 1;
366 for (sp
= ndmntp
->ndm_path
; *sp
&& dp
< endp
;)
375 * Get an mbuf with the given length, and
376 * initialize the pkthdr length field.
379 mbuf_get_with_len(int msg_len
, mbuf_t
*m
)
382 error
= mbuf_gethdr(MBUF_WAITOK
, MBUF_TYPE_DATA
, m
);
385 if (msg_len
> mbuf_maxlen(*m
)) {
386 error
= mbuf_mclget(MBUF_WAITOK
, MBUF_TYPE_DATA
, m
);
391 if (msg_len
> mbuf_maxlen(*m
))
392 panic("nfs_boot: msg_len > MCLBYTES");
394 mbuf_setlen(*m
, msg_len
);
395 mbuf_pkthdr_setlen(*m
, msg_len
);
401 * String representation for RPC.
404 u_long len
; /* length without null or padding */
405 u_char data
[4]; /* data (longer, of course) */
406 /* data is padded to a long-word boundary */
408 /* Compute space used given string length. */
409 #define RPC_STR_SIZE(slen) (4 + ((slen + 3) & ~3))
412 * Inet address in RPC messages
413 * (Note, really four longs, NOT chars. Blech.)
422 * RPC: bootparam/whoami
423 * Given client IP address, get:
424 * client name (hostname)
425 * domain name (domainname)
428 * The hostname and domainname are set here for convenience.
430 * Note - bpsin is initialized to the broadcast address,
431 * and will be replaced with the bootparam server address
432 * after this call is complete. Have to use PMAP_PROC_CALL
433 * to make sure we get responses only from a servers that
434 * know about us (don't want to broadcast a getport call).
437 bp_whoami(bpsin
, my_ip
, gw_ip
)
438 struct sockaddr_in
*bpsin
;
439 struct in_addr
*my_ip
;
440 struct in_addr
*gw_ip
;
442 /* RPC structures for PMAPPROC_CALLIT */
448 struct bp_inaddr call_ia
;
451 struct rpc_string
*str
;
452 struct bp_inaddr
*bia
;
454 struct sockaddr_in sin
;
461 * Get message buffer of sufficient size.
463 msg_len
= sizeof(*call
);
464 error
= mbuf_get_with_len(msg_len
, &m
);
469 * Build request message for PMAPPROC_CALLIT.
472 call
->call_prog
= htonl(BOOTPARAM_PROG
);
473 call
->call_vers
= htonl(BOOTPARAM_VERS
);
474 call
->call_proc
= htonl(BOOTPARAM_WHOAMI
);
475 call
->call_arglen
= htonl(sizeof(struct bp_inaddr
));
477 /* client IP address */
478 call
->call_ia
.atype
= htonl(1);
480 lp
= call
->call_ia
.addr
;
481 *lp
++ = htonl(*p
); p
++;
482 *lp
++ = htonl(*p
); p
++;
483 *lp
++ = htonl(*p
); p
++;
484 *lp
++ = htonl(*p
); p
++;
486 /* RPC: portmap/callit */
487 bpsin
->sin_port
= htons(PMAPPORT
);
489 error
= krpc_call(bpsin
, SOCK_DGRAM
, PMAPPROG
, PMAPVERS
, PMAPPROC_CALLIT
, &m
, &sin
);
494 * Parse result message.
496 msg_len
= mbuf_len(m
);
499 /* bootparam server port (also grab from address). */
500 if (msg_len
< (int)sizeof(*lp
))
502 msg_len
-= sizeof(*lp
);
503 bpsin
->sin_port
= htons((short)ntohl(*lp
++));
504 bpsin
->sin_addr
.s_addr
= sin
.sin_addr
.s_addr
;
506 /* length of encapsulated results */
507 if (msg_len
< (ntohl(*lp
) + (int)sizeof(*lp
)))
509 msg_len
= ntohl(*lp
++);
513 if (msg_len
< (int)sizeof(*str
))
515 str
= (struct rpc_string
*)p
;
516 cn_len
= ntohl(str
->len
);
517 if (msg_len
< cn_len
)
519 if (cn_len
>= MAXHOSTNAMELEN
)
521 bcopy(str
->data
, hostname
, cn_len
);
522 hostname
[cn_len
] = '\0';
523 hostnamelen
= cn_len
;
524 p
+= RPC_STR_SIZE(cn_len
);
525 msg_len
-= RPC_STR_SIZE(cn_len
);
528 if (msg_len
< (int)sizeof(*str
))
530 str
= (struct rpc_string
*)p
;
531 dn_len
= ntohl(str
->len
);
532 if (msg_len
< dn_len
)
534 if (dn_len
>= MAXHOSTNAMELEN
)
536 bcopy(str
->data
, domainname
, dn_len
);
537 domainname
[dn_len
] = '\0';
538 domainnamelen
= dn_len
;
539 p
+= RPC_STR_SIZE(dn_len
);
540 msg_len
-= RPC_STR_SIZE(dn_len
);
542 /* gateway address */
543 if (msg_len
< (int)sizeof(*bia
))
545 bia
= (struct bp_inaddr
*)p
;
546 if (bia
->atype
!= htonl(1))
549 *p
++ = ntohl(bia
->addr
[0]);
550 *p
++ = ntohl(bia
->addr
[1]);
551 *p
++ = ntohl(bia
->addr
[2]);
552 *p
++ = ntohl(bia
->addr
[3]);
556 printf("nfs_boot: bootparam_whoami: bad reply\n");
566 * RPC: bootparam/getfile
567 * Given client name and file "key", get:
573 bp_getfile(bpsin
, key
, md_sin
, serv_name
, pathname
)
574 struct sockaddr_in
*bpsin
;
576 struct sockaddr_in
*md_sin
;
580 struct rpc_string
*str
;
582 struct bp_inaddr
*bia
;
583 struct sockaddr_in
*sin
;
586 int cn_len
, key_len
, sn_len
, path_len
;
589 * Get message buffer of sufficient size.
591 cn_len
= hostnamelen
;
592 key_len
= strlen(key
);
594 msg_len
+= RPC_STR_SIZE(cn_len
);
595 msg_len
+= RPC_STR_SIZE(key_len
);
596 error
= mbuf_get_with_len(msg_len
, &m
);
601 * Build request message.
605 /* client name (hostname) */
606 str
= (struct rpc_string
*)p
;
607 str
->len
= htonl(cn_len
);
608 bcopy(hostname
, str
->data
, cn_len
);
609 p
+= RPC_STR_SIZE(cn_len
);
610 /* key name (root or swap) */
611 str
= (struct rpc_string
*)p
;
612 str
->len
= htonl(key_len
);
613 bcopy(key
, str
->data
, key_len
);
615 /* RPC: bootparam/getfile */
616 error
= krpc_call(bpsin
, SOCK_DGRAM
, BOOTPARAM_PROG
, BOOTPARAM_VERS
,
617 BOOTPARAM_GETFILE
, &m
, NULL
);
622 * Parse result message.
625 msg_len
= mbuf_len(m
);
628 if (msg_len
< (int)sizeof(*str
))
630 str
= (struct rpc_string
*)p
;
631 sn_len
= ntohl(str
->len
);
632 if (msg_len
< sn_len
)
634 if (sn_len
>= MNAMELEN
)
636 bcopy(str
->data
, serv_name
, sn_len
);
637 serv_name
[sn_len
] = '\0';
638 p
+= RPC_STR_SIZE(sn_len
);
639 msg_len
-= RPC_STR_SIZE(sn_len
);
641 /* server IP address (mountd) */
642 if (msg_len
< (int)sizeof(*bia
))
644 bia
= (struct bp_inaddr
*)p
;
645 if (bia
->atype
!= htonl(1))
648 bzero((caddr_t
)sin
, sizeof(*sin
));
649 sin
->sin_len
= sizeof(*sin
);
650 sin
->sin_family
= AF_INET
;
651 q
= (u_char
*) &sin
->sin_addr
;
652 *q
++ = ntohl(bia
->addr
[0]);
653 *q
++ = ntohl(bia
->addr
[1]);
654 *q
++ = ntohl(bia
->addr
[2]);
655 *q
++ = ntohl(bia
->addr
[3]);
657 msg_len
-= sizeof(*bia
);
659 /* server pathname */
660 if (msg_len
< (int)sizeof(*str
))
662 str
= (struct rpc_string
*)p
;
663 path_len
= ntohl(str
->len
);
664 if (msg_len
< path_len
)
666 if (path_len
>= MAXPATHLEN
)
668 bcopy(str
->data
, pathname
, path_len
);
669 pathname
[path_len
] = '\0';
673 printf("nfs_boot: bootparam_getfile: bad reply\n");
684 * Given a server pathname, get an NFS file handle.
685 * Also, sets sin->sin_port to the NFS service port.
688 md_mount(mdsin
, path
, v3
, sotype
, fhp
, fhlenp
)
689 struct sockaddr_in
*mdsin
; /* mountd server address */
696 /* The RPC structures */
697 struct rpc_string
*str
;
700 u_char data
[NFSX_V3FHMAX
+ sizeof(u_long
)];
703 int error
, mlen
, slen
;
704 int mntversion
= v3
? RPCMNT_VER3
: RPCMNT_VER1
;
705 int proto
= (sotype
== SOCK_STREAM
) ? IPPROTO_TCP
: IPPROTO_UDP
;
706 in_port_t mntport
, nfsport
;
708 /* Get port number for MOUNTD. */
709 error
= krpc_portmap(mdsin
, RPCPROG_MNT
, mntversion
, proto
, &mntport
);
713 /* Get port number for NFS use. */
714 /* (If NFS/proto unavailable, don't bother with the mount call) */
715 error
= krpc_portmap(mdsin
, NFS_PROG
, v3
? NFS_VER3
: NFS_VER2
, proto
, &nfsport
);
719 /* Set port number for MOUNTD */
720 mdsin
->sin_port
= mntport
;
723 mlen
= RPC_STR_SIZE(slen
);
725 error
= mbuf_get_with_len(mlen
, &m
);
729 str
->len
= htonl(slen
);
730 bcopy(path
, str
->data
, slen
);
732 /* Do RPC to mountd. */
733 error
= krpc_call(mdsin
, sotype
, RPCPROG_MNT
, mntversion
, RPCMNT_MOUNT
, &m
, NULL
);
735 return error
; /* message already freed */
738 * the reply must be long enough to hold the errno plus either of:
740 * + a v3 filehandle length + a v3 filehandle
743 if (mlen
< (int)sizeof(u_long
))
745 rdata
= mbuf_data(m
);
746 error
= ntohl(rdata
->errno
);
752 if (mlen
< (int)sizeof(u_long
)*2)
754 fhlen
= ntohl(*(u_long
*)rdata
->data
);
755 fh
= rdata
->data
+ sizeof(u_long
);
756 if (mlen
< (int)(sizeof(u_long
)*2 + fhlen
))
758 bcopy(fh
, fhp
, fhlen
);
761 if (mlen
< ((int)sizeof(u_long
) + NFSX_V2FH
))
763 bcopy(rdata
->data
, fhp
, NFSX_V2FH
);
767 /* Set port number for NFS use. */
768 mdsin
->sin_port
= nfsport
;