2 * Copyright (c) 1992, 1993, 1994
3 * The Regents of the University of California. All rights reserved.
5 * This code is derived from software contributed to Berkeley by
6 * Rick Macklem at The University of Guelph.
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
16 * 3. All advertising materials mentioning features or use of this software
17 * must display the following acknowledgement:
18 * This product includes software developed by the University of
19 * California, Berkeley and its contributors.
20 * 4. Neither the name of the University nor the names of its contributors
21 * may be used to endorse or promote products derived from this software
22 * without specific prior written permission.
24 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
25 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
28 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
30 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
38 static const char copyright[] =
39 "@(#) Copyright (c) 1992, 1993, 1994\n\
40 The Regents of the University of California. All rights reserved.\n";
45 static char sccsid[] = "@(#)mount_nfs.c 8.11 (Berkeley) 5/4/95";
47 static const char rcsid[] =
48 "$Id: mount_nfs.c,v 1.29 1998/07/06 07:15:53 charnier Exp $";
51 #include <sys/param.h>
52 #include <sys/mount.h>
54 #include <sys/syslog.h>
57 #include <rpc/pmap_clnt.h>
58 #include <rpc/pmap_prot.h>
61 #include <netiso/iso.h>
65 #include <kerberosIV/des.h>
66 #include <kerberosIV/krb.h>
69 #include <sys/vnode.h>
75 #include <nfs/rpcv2.h>
76 #include <nfs/nfsproto.h>
78 #include <nfs/nqnfs.h>
80 #include <arpa/inet.h>
96 #define ALTF_NOCONN 0x2
97 #define ALTF_DUMBTIMR 0x4
99 #define ALTF_KERB 0x10
100 #define ALTF_NFSV3 0x20
101 #define ALTF_RDIRPLUS 0x40
102 #define ALTF_MNTUDP 0x80
103 #define ALTF_RESVPORT 0x100
104 #define ALTF_SEQPACKET 0x200
105 #define ALTF_NQNFS 0x400
106 #define ALTF_SOFT 0x800
107 #define ALTF_TCP 0x1000
108 #define ALTF_PORT 0x2000
109 #define ALTF_NFSV2 0x4000
110 #define ALTF_ACREGMIN 0x8000
111 #define ALTF_ACREGMAX 0x10000
112 #define ALTF_ACDIRMIN 0x20000
113 #define ALTF_ACDIRMAX 0x40000
115 struct mntopt mopts[] = {
120 { "bg", 0, ALTF_BG, 1 },
121 { "conn", 1, ALTF_NOCONN, 1 },
122 { "dumbtimer", 0, ALTF_DUMBTIMR, 1 },
123 { "intr", 0, ALTF_INTR, 1 },
125 { "kerb", 0, ALTF_KERB, 1 },
127 { "nfsv3", 0, ALTF_NFSV3, 1 },
128 { "rdirplus", 0, ALTF_RDIRPLUS, 1 },
129 { "mntudp", 0, ALTF_MNTUDP, 1 },
130 { "resvport", 0, ALTF_RESVPORT, 1 },
132 { "seqpacket", 0, ALTF_SEQPACKET, 1 },
134 { "nqnfs", 0, ALTF_NQNFS, 1 },
135 { "soft", 0, ALTF_SOFT, 1 },
136 { "tcp", 0, ALTF_TCP, 1 },
137 { "port=", 0, ALTF_PORT, 1 },
138 { "nfsv2", 0, ALTF_NFSV2, 1 },
139 { "acregmin=", 0, ALTF_ACREGMIN, 1 },
140 { "acregmax=", 0, ALTF_ACREGMAX, 1 },
141 { "acdirmin=", 0, ALTF_ACDIRMIN, 1 },
142 { "acdirmax=", 0, ALTF_ACDIRMAX, 1 },
146 struct u9fs_args u9fsdefargs = {
148 (struct sockaddr *)0,
149 sizeof (struct sockaddr_in),
169 u_char nfh[NFSX_V3FHMAX];
171 #define DEF_RETRY 10000
174 int retrycnt = DEF_RETRY;
176 int nfsproto = IPPROTO_UDP;
187 char realm[REALM_SZ];
192 struct nfsrpc_nickverf kverf;
193 struct nfsrpc_fullblock kin, kout;
197 NFSKERBKEYSCHED_T kerb_keysched;
200 int getnfsargs __P((char *, struct u9fs_args *));
202 struct iso_addr *iso_addr __P((const char *));
204 void set_rpc_maxgrouplist __P((int));
205 void usage __P((void)) __dead2;
206 int xdr_dir __P((XDR *, char *));
207 int xdr_fh __P((XDR *, struct nfhret *));
209 void gethostaddr(char * hostp, struct sockaddr_in * saddr);
212 * Used to set mount flags with getmntopts. Call with dir=TRUE to
213 * initialize altflags from the current mount flags. Call with
214 * dir=FALSE to update mount flags with the new value of altflags after
215 * the call to getmntopts.
218 setflags(int* altflags, int* nfsflags, int dir)
222 if (*nfsflags & NFSMNT_##nf) \
223 *altflags |= ALTF_##af; \
225 *altflags &= ~ALTF_##af; \
227 if (*altflags & ALTF_##af) \
228 *nfsflags |= NFSMNT_##nf; \
230 *nfsflags &= ~NFSMNT_##nf; \
255 register struct u9fs_args *nfsargsp;
256 struct u9fs_args u9fsargs;
257 struct nfsd_cargs ncd;
258 int mntflags, altflags, i, nfssvc_flag, num;
259 char *name, *p, *spec;
262 static struct sockaddr_in authaddr;
268 (void)strcpy(realm, KRB_REALM);
269 if (sizeof (struct nfsrpc_nickverf) != RPCX_NICKVERF ||
270 sizeof (struct nfsrpc_fullblock) != RPCX_FULLBLOCK ||
271 ((char *)&ktick.kt) - ((char *)&ktick) != NFSX_UNSIGNED ||
272 ((char *)ktick.kt.dat) - ((char *)&ktick) != 2 * NFSX_UNSIGNED)
273 fprintf(stderr, "Yikes! NFSKERB structs not packed!!\n");
275 retrycnt = DEF_RETRY;
279 u9fsargs = u9fsdefargs;
280 nfsargsp = &u9fsargs;
281 while ((c = getopt(argc, argv,
282 "23a:bcdD:g:I:iKL:lm:No:PpqR:r:sTt:w:x:Uu:")) != -1)
291 num = strtol(optarg, &p, 10);
293 errx(1, "illegal -a value -- %s", optarg);
295 nfsargsp->readahead = num;
296 nfsargsp->flags |= NFSMNT_READAHEAD;
303 nfsargsp->flags |= NFSMNT_NOCONN;
306 num = strtol(optarg, &p, 10);
308 errx(1, "illegal -D value -- %s", optarg);
310 nfsargsp->deadthresh = num;
311 nfsargsp->flags |= NFSMNT_DEADTHRESH;
315 nfsargsp->flags |= NFSMNT_DUMBTIMR;
318 num = strtol(optarg, &p, 10);
320 errx(1, "illegal -g value -- %s", optarg);
322 set_rpc_maxgrouplist(num);
325 nfsargsp->maxgrouplist = num;
326 nfsargsp->flags |= NFSMNT_MAXGRPS;
330 num = strtol(optarg, &p, 10);
332 errx(1, "illegal -I value -- %s", optarg);
333 nfsargsp->readdirsize = num;
334 nfsargsp->flags |= NFSMNT_READDIRSIZE;
337 nfsargsp->flags |= NFSMNT_INT;
341 nfsargsp->flags |= NFSMNT_KERB;
345 num = strtol(optarg, &p, 10);
347 errx(1, "illegal -L value -- %s", optarg);
349 nfsargsp->leaseterm = num;
350 nfsargsp->flags |= NFSMNT_LEASETERM;
354 nfsargsp->flags |= NFSMNT_RDIRPLUS;
358 (void)strncpy(realm, optarg, REALM_SZ - 1);
359 realm[REALM_SZ - 1] = '\0';
363 nfsargsp->flags &= ~NFSMNT_RESVPORT;
367 setflags(&altflags, &nfsargsp->flags, TRUE);
369 altflags |= ALTF_NFSV2;
370 else if (mountmode == V3)
371 altflags |= ALTF_NFSV3;
372 getmntopts(optarg, mopts, &mntflags, &altflags);
373 setflags(&altflags, &nfsargsp->flags, FALSE);
375 * Handle altflags which don't map directly to
378 if(altflags & ALTF_BG)
380 if(altflags & ALTF_MNTUDP)
383 if(altflags & ALTF_SEQPACKET)
384 nfsargsp->sotype = SOCK_SEQPACKET;
386 if(altflags & ALTF_TCP) {
387 nfsargsp->sotype = SOCK_STREAM;
388 nfsproto = IPPROTO_TCP;
390 if(altflags & ALTF_PORT)
391 port_no = atoi(strstr(optarg, "port=") + 5);
393 if(altflags & ALTF_NFSV2)
395 if(altflags & ALTF_NFSV3)
398 if(altflags & ALTF_ACREGMIN)
399 nfsargsp->acregmin = atoi(strstr(optarg,
401 if(altflags & ALTF_ACREGMAX)
402 nfsargsp->acregmax = atoi(strstr(optarg,
404 if(altflags & ALTF_ACDIRMIN)
405 nfsargsp->acdirmin = atoi(strstr(optarg,
407 if(altflags & ALTF_ACDIRMAX)
408 nfsargsp->acdirmax = atoi(strstr(optarg,
413 /* obsolete for NFSMNT_RESVPORT, now default */
417 nfsargsp->sotype = SOCK_SEQPACKET;
422 nfsargsp->flags |= NFSMNT_NQNFS;
425 num = strtol(optarg, &p, 10);
427 errx(1, "illegal -R value -- %s", optarg);
431 num = strtol(optarg, &p, 10);
433 errx(1, "illegal -r value -- %s", optarg);
434 nfsargsp->rsize = num;
435 nfsargsp->flags |= NFSMNT_RSIZE;
438 nfsargsp->flags |= NFSMNT_SOFT;
441 nfsargsp->sotype = SOCK_STREAM;
442 nfsproto = IPPROTO_TCP;
445 num = strtol(optarg, &p, 10);
447 errx(1, "illegal -t value -- %s", optarg);
449 nfsargsp->timeo = num;
450 nfsargsp->flags |= NFSMNT_TIMEO;
454 num = strtol(optarg, &p, 10);
456 errx(1, "illegal -w value -- %s", optarg);
457 nfsargsp->wsize = num;
458 nfsargsp->flags |= NFSMNT_WSIZE;
461 num = strtol(optarg, &p, 10);
463 errx(1, "illegal -x value -- %s", optarg);
465 nfsargsp->retrans = num;
466 nfsargsp->flags |= NFSMNT_RETRANS;
473 if( (p = index(optarg, '@')) ) {
475 strncpy(nfsargsp->uname, optarg, U9FS_NAMELEN);
476 gethostaddr(p, & authaddr);
477 authaddr.sin_family = AF_INET;
478 authaddr.sin_port = htons(U9AUTH_ILPORT);
479 nfsargsp->authaddr = (struct sockaddr *) & authaddr;
480 nfsargsp->authaddrlen = sizeof(authaddr);
482 strncpy(nfsargsp->uname, optarg, U9FS_NAMELEN);
499 if (!getnfsargs(spec, nfsargsp))
503 error = getvfsbyname("u9fs", &vfc);
504 if (error && vfsisloadable("nfs")) {
506 err(EX_OSERR, "vfsload(nfs)");
507 endvfsent(); /* clear cache */
508 error = getvfsbyname("nfs", &vfc);
511 errx(EX_OSERR, "nfs filesystem is not available");
513 if (mount(vfc.vfc_name, name, mntflags, nfsargsp))
516 if (mount("nfs", name, mntflags, nfsargsp))
519 if (nfsargsp->flags & (NFSMNT_NQNFS | NFSMNT_KERB)) {
520 if ((opflags & ISBGRND) == 0) {
527 (void) close(STDIN_FILENO);
528 (void) close(STDOUT_FILENO);
529 (void) close(STDERR_FILENO);
532 openlog("mount_nfs:", LOG_PID, LOG_DAEMON);
533 nfssvc_flag = NFSSVC_MNTD;
535 while (nfssvc(nfssvc_flag, (caddr_t)&ncd) < 0) {
536 if (errno != ENEEDAUTH) {
537 syslog(LOG_ERR, "nfssvc err %m");
541 NFSSVC_MNTD | NFSSVC_GOTAUTH | NFSSVC_AUTHINFAIL;
544 * Set up as ncd_authuid for the kerberos call.
545 * Must set ruid to ncd_authuid and reset the
546 * ticket name iff ncd_authuid is not the same
547 * as last time, so that the right ticket file
549 * Get the Kerberos credential structure so that
550 * we have the session key and get a ticket for
552 * For more info see the IETF Draft "Authentication
555 if (ncd.ncd_authuid != last_ruid) {
557 (void)sprintf(buf, "%s%d",
558 TKT_ROOT, ncd.ncd_authuid);
559 krb_set_tkt_string(buf);
560 last_ruid = ncd.ncd_authuid;
562 setreuid(ncd.ncd_authuid, 0);
563 kret = krb_get_cred(NFS_KERBSRV, inst, realm, &kcr);
564 if (kret == RET_NOTKT) {
565 kret = get_ad_tkt(NFS_KERBSRV, inst, realm,
567 if (kret == KSUCCESS)
568 kret = krb_get_cred(NFS_KERBSRV, inst, realm,
571 if (kret == KSUCCESS)
572 kret = krb_mk_req(&ktick.kt, NFS_KERBSRV, inst,
576 * Fill in the AKN_FULLNAME authenticator and verifier.
577 * Along with the Kerberos ticket, we need to build
578 * the timestamp verifier and encrypt it in CBC mode.
580 if (kret == KSUCCESS &&
581 ktick.kt.length <= (RPCAUTH_MAXSIZ-3*NFSX_UNSIGNED)
582 && gettimeofday(&ktv, (struct timezone *)0) == 0) {
583 ncd.ncd_authtype = RPCAUTH_KERB4;
584 ncd.ncd_authstr = (u_char *)&ktick;
585 ncd.ncd_authlen = nfsm_rndup(ktick.kt.length) +
587 ncd.ncd_verfstr = (u_char *)&kverf;
588 ncd.ncd_verflen = sizeof (kverf);
589 memmove(ncd.ncd_key, kcr.session,
590 sizeof (kcr.session));
591 kin.t1 = htonl(ktv.tv_sec);
592 kin.t2 = htonl(ktv.tv_usec);
593 kin.w1 = htonl(NFS_KERBTTL);
594 kin.w2 = htonl(NFS_KERBTTL - 1);
595 bzero((caddr_t)kivec, sizeof (kivec));
598 * Encrypt kin in CBC mode using the session
604 * Finally, fill the timestamp verifier into the
605 * authenticator and verifier.
607 ktick.kind = htonl(RPCAKN_FULLNAME);
608 kverf.kind = htonl(RPCAKN_FULLNAME);
609 NFS_KERBW1(ktick.kt) = kout.w1;
610 ktick.kt.length = htonl(ktick.kt.length);
611 kverf.verf.t1 = kout.t1;
612 kverf.verf.t2 = kout.t2;
613 kverf.verf.w2 = kout.w2;
614 nfssvc_flag = NFSSVC_MNTD | NFSSVC_GOTAUTH;
624 * Return RPC_SUCCESS if server responds.
627 pingnfsserver(addr, version, sotype)
628 struct sockaddr_in *addr;
632 struct sockaddr_in sin;
635 int so = RPC_ANYSOCK;
637 struct timeval pertry, try;
641 if ((tport = port_no ? port_no :
642 pmap_getport(&sin, RPCPROG_NFS, version, nfsproto)) == 0) {
643 return rpc_createerr.cf_stat;
646 sin.sin_port = htons(tport);
650 if (sotype == SOCK_STREAM)
651 clp = clnttcp_create(&sin, RPCPROG_NFS, version,
654 clp = clntudp_create(&sin, RPCPROG_NFS, version,
657 return rpc_createerr.cf_stat;
661 stat = clnt_call(clp, NFSPROC_NULL,
662 xdr_void, NULL, xdr_void, NULL, try);
669 int load_9uid(struct u9fs_args * nfsargsp)
674 struct p9user * p9p, * p9alloc;
676 if( (fd = fopen("/etc/9uid.conf", "r")) == 0 )
680 if( (p9alloc = malloc(siz*sizeof(struct p9user))) == 0 )
687 if ( fgets(line, 80, fd) == 0 )
690 if ( strsep(&cp, " \t") == 0 )
691 errx(1, "bad format in 9uid.conf");
692 p9p->p9_uid = atoi(cp);
693 strncpy(p9p->p9_name, line, U9FS_NAMELEN);
697 if( (p9p = realloc(p9alloc, 2*siz*sizeof(struct p9user))) == 0 )
705 nfsargsp->nusers = nusers;
706 nfsargsp->users = p9alloc;
712 passtokey(char *key, char *p)
714 u_char buf[U9FS_NAMELEN], *t;
718 if(n >= U9FS_NAMELEN)
722 strncpy((char*)t, p, n);
724 memset(key, 0, U9AUTH_DESKEYLEN);
726 for(i = 0; i < U9AUTH_DESKEYLEN; i++)
727 key[i] = (t[i] >> i) + (t[i+1] << (8 - (i+1)));
738 return 1; /* not reached */
741 void load_9key(struct u9fs_args * nfsargsp)
745 p = getpass("Plan 9 Password: ");
746 passtokey(nfsargsp->key, p);
749 void gethostaddr(char * hostp, struct sockaddr_in * saddr)
753 * Handle an internet host address and reverse resolve it if
756 if (isdigit(*hostp)) {
757 if ((saddr->sin_addr.s_addr = inet_addr(hostp)) == -1) {
758 warnx("bad net address %s", hostp);
760 } else if ((hp = gethostbyname(hostp)) != NULL)
761 memmove(&saddr->sin_addr, hp->h_addr,
762 MIN(hp->h_length, sizeof(saddr->sin_addr)));
764 warnx("can't get net id for host");
769 getnfsargs(spec, nfsargsp)
771 struct u9fs_args *nfsargsp;
773 register CLIENT *clp;
775 static struct sockaddr_in saddr;
777 static struct sockaddr_iso isoaddr;
778 struct iso_addr *isop;
781 struct timeval pertry, try;
782 enum clnt_stat clnt_stat;
783 int so = RPC_ANYSOCK, i, nfsvers, mntvers, orgcnt;
784 char *hostp, *delimp;
789 static struct nfhret nfhret;
790 static char nam[MNAMELEN + 1];
792 strncpy(nam, spec, MNAMELEN);
793 nam[MNAMELEN] = '\0';
794 if ((delimp = strchr(spec, '@')) != NULL) {
796 } else if ((delimp = strchr(spec, ':')) != NULL) {
800 warnx("no <host>:<dirpath> or <dirpath>@<host> spec");
805 * DUMB!! Until the mount protocol works on iso transport, we must
806 * supply both an iso and an inet address for the host.
809 if (!strncmp(hostp, "iso=", 4)) {
814 if ((delimp = strchr(hostp, '+')) == NULL) {
815 warnx("no iso+inet address");
819 if ((isop = iso_addr(hostp)) == NULL) {
820 warnx("bad ISO address");
823 memset(&isoaddr, 0, sizeof (isoaddr));
824 memmove(&isoaddr.siso_addr, isop, sizeof (struct iso_addr));
825 isoaddr.siso_len = sizeof (isoaddr);
826 isoaddr.siso_family = AF_ISO;
827 isoaddr.siso_tlen = 2;
828 isoport = htons(NFS_PORT);
829 memmove(TSEL(&isoaddr), &isoport, isoaddr.siso_tlen);
834 gethostaddr(hostp, & saddr);
836 if ((nfsargsp->flags & NFSMNT_KERB)) {
837 if ((hp = gethostbyaddr((char *)&saddr.sin_addr.s_addr,
838 sizeof (u_long), AF_INET)) == (struct hostent *)0) {
839 warnx("can't reverse resolve net address");
842 memmove(&saddr.sin_addr, hp->h_addr,
843 MIN(hp->h_length, sizeof(saddr.sin_addr)));
844 strncpy(inst, hp->h_name, INST_SZ);
845 inst[INST_SZ - 1] = '\0';
846 if (cp = strchr(inst, '.'))
853 if (mountmode == ANY || mountmode == V3) {
856 nfsargsp->flags |= NFSMNT_NFSV3;
860 nfsargsp->flags &= ~NFSMNT_NFSV3;
862 tport = port_no ? port_no : U9FS_PORT;
865 nfhret.stat = EACCES; /* Mark not yet successful */
866 while (retrycnt > 0) {
867 saddr.sin_family = AF_INET;
868 saddr.sin_port = htons(PMAPPORT);
869 if ((tport = port_no ? port_no :
870 pmap_getport(&saddr, RPCPROG_NFS,
871 nfsvers, nfsproto)) == 0) {
872 if ((opflags & ISBGRND) == 0)
873 clnt_pcreateerror("NFS Portmap");
876 * First ping the nfs server to see if it supports
877 * the version of the protocol we want to use.
879 clnt_stat = pingnfsserver(&saddr, nfsvers,
881 if (clnt_stat == RPC_PROGVERSMISMATCH) {
882 if (mountmode == ANY) {
886 errx(1, "can't contact NFS server");
892 if (mnttcp_ok && nfsargsp->sotype == SOCK_STREAM)
893 clp = clnttcp_create(&saddr, RPCPROG_MNT, mntvers,
896 clp = clntudp_create(&saddr, RPCPROG_MNT, mntvers,
899 if ((opflags & ISBGRND) == 0)
900 clnt_pcreateerror("Cannot MNT RPC");
902 clp->cl_auth = authunix_create_default();
905 if (nfsargsp->flags & NFSMNT_KERB)
906 nfhret.auth = RPCAUTH_KERB4;
908 nfhret.auth = RPCAUTH_UNIX;
909 nfhret.vers = mntvers;
910 clnt_stat = clnt_call(clp, RPCMNT_MOUNT,
911 xdr_dir, spec, xdr_fh, &nfhret, try);
912 if (clnt_stat != RPC_SUCCESS) {
913 if (clnt_stat == RPC_PROGVERSMISMATCH) {
914 if (mountmode == ANY) {
919 clnt_sperror(clp, "MNT RPC"));
922 if ((opflags & ISBGRND) == 0)
923 warnx("%s", clnt_sperror(clp,
926 auth_destroy(clp->cl_auth);
932 if (--retrycnt > 0) {
933 if (opflags & BGRND) {
941 (void) close(STDIN_FILENO);
942 (void) close(STDOUT_FILENO);
943 (void) close(STDERR_FILENO);
951 if (opflags & ISBGRND)
953 warnx("can't access %s: %s", spec, strerror(nfhret.stat));
957 saddr.sin_family = AF_INET;
958 saddr.sin_port = htons(tport);
961 nfsargsp->addr = (struct sockaddr *) &isoaddr;
962 nfsargsp->addrlen = sizeof (isoaddr);
966 nfsargsp->addr = (struct sockaddr *) &saddr;
967 nfsargsp->addrlen = sizeof (saddr);
970 nfsargsp->fh = nfhret.nfh;
972 nfsargsp->fhsize = nfhret.fhsize;
973 nfsargsp->hostname = nam;
976 if( load_9uid(nfsargsp) )
977 errx(1, "can't load 9uid.conf");
983 * xdr routines for mount rpc's
990 return (xdr_string(xdrsp, &dirp, RPCMNT_PATHLEN));
996 register struct nfhret *np;
999 long auth, authcnt, authfnd = 0;
1001 if (!xdr_u_long(xdrsp, &np->stat))
1007 np->fhsize = NFSX_V2FH;
1008 return (xdr_opaque(xdrsp, (caddr_t)np->nfh, NFSX_V2FH));
1010 if (!xdr_long(xdrsp, &np->fhsize))
1012 if (np->fhsize <= 0 || np->fhsize > NFSX_V3FHMAX)
1014 if (!xdr_opaque(xdrsp, (caddr_t)np->nfh, np->fhsize))
1016 if (!xdr_long(xdrsp, &authcnt))
1018 for (i = 0; i < authcnt; i++) {
1019 if (!xdr_long(xdrsp, &auth))
1021 if (auth == np->auth)
1025 * Some servers, such as DEC's OSF/1 return a nil authenticator
1026 * list to indicate RPCAUTH_UNIX.
1028 if (!authfnd && (authcnt > 0 || np->auth != RPCAUTH_UNIX))
1038 (void)fprintf(stderr, "%s\n%s\n%s\n%s\n",
1039 "usage: mount_nfs [-23KNPTUbcdilqs] [-D deadthresh] [-I readdirsize]",
1040 " [-L leaseterm] [-R retrycnt] [-a maxreadahead]",
1041 " [-g maxgroups] [-m realm] [-o options] [-r readsize]",
1042 " [-t timeout] [-w writesize] [-x retrans] rhost:path node");