+ if (fslist == NULL)
+ return (NULL);
+ if (fslist[0] == 'n' && fslist[1] == 'o') {
+ fslist += 2;
+ skipvfs = 1;
+ }
+ for (i = 0, nextcp = fslist; *nextcp; nextcp++)
+ if (*nextcp == ',')
+ i++;
+ av = (char **)malloc((size_t)(i+2) * sizeof(char *));
+ if (av == NULL)
+ return (NULL);
+ nextcp = fslist;
+ i = 0;
+ av[i++] = nextcp;
+ while (nextcp = index(nextcp, ',')) {
+ *nextcp++ = '\0';
+ av[i++] = nextcp;
+ }
+ av[i++] = 0;
+ return (av);
+}
+
+#ifdef NFS
+exclusive(a, b)
+ char *a, *b;
+{
+
+ (void) fprintf(stderr, "mount: Options %s, %s mutually exclusive\n",
+ a, b);
+ exit(1);
+}
+
+/*
+ * Handle the getoption arg.
+ * Essentially update "opflags", "retrycnt" and "nfsargs"
+ */
+getnfsopts(optarg, nfsargsp, opflagsp, retrycntp)
+ char *optarg;
+ register struct nfs_args *nfsargsp;
+ int *opflagsp;
+ int *retrycntp;
+{
+ register char *cp, *nextcp;
+ int num;
+ char *nump;
+
+ for (cp = optarg; cp != NULL && *cp != '\0'; cp = nextcp) {
+ if ((nextcp = index(cp, ',')) != NULL)
+ *nextcp++ = '\0';
+ if ((nump = index(cp, '=')) != NULL) {
+ *nump++ = '\0';
+ num = atoi(nump);
+ } else
+ num = -1;
+ /*
+ * Just test for a string match and do it
+ */
+ if (!strcmp(cp, "bg")) {
+ *opflagsp |= BGRND;
+ } else if (!strcmp(cp, "soft")) {
+ if (nfsargsp->flags & NFSMNT_SPONGY)
+ exclusive("soft, spongy");
+ nfsargsp->flags |= NFSMNT_SOFT;
+ } else if (!strcmp(cp, "spongy")) {
+ if (nfsargsp->flags & NFSMNT_SOFT)
+ exclusive("soft, spongy");
+ nfsargsp->flags |= NFSMNT_SPONGY;
+ } else if (!strcmp(cp, "compress")) {
+ nfsargsp->flags |= NFSMNT_COMPRESS;
+ } else if (!strcmp(cp, "intr")) {
+ nfsargsp->flags |= NFSMNT_INT;
+ } else if (!strcmp(cp, "tcp")) {
+ nfsargsp->sotype = SOCK_STREAM;
+ } else if (!strcmp(cp, "noconn")) {
+ nfsargsp->flags |= NFSMNT_NOCONN;
+ } else if (!strcmp(cp, "retry") && num > 0) {
+ *retrycntp = num;
+ } else if (!strcmp(cp, "rsize") && num > 0) {
+ nfsargsp->rsize = num;
+ nfsargsp->flags |= NFSMNT_RSIZE;
+ } else if (!strcmp(cp, "wsize") && num > 0) {
+ nfsargsp->wsize = num;
+ nfsargsp->flags |= NFSMNT_WSIZE;
+ } else if (!strcmp(cp, "timeo") && num > 0) {
+ nfsargsp->timeo = num;
+ nfsargsp->flags |= NFSMNT_TIMEO;
+ } else if (!strcmp(cp, "retrans") && num > 0) {
+ nfsargsp->retrans = num;
+ nfsargsp->flags |= NFSMNT_RETRANS;
+ }
+ }
+ if (nfsargsp->sotype == SOCK_DGRAM) {
+ if (nfsargsp->rsize > NFS_MAXDGRAMDATA)
+ nfsargsp->rsize = NFS_MAXDGRAMDATA;
+ if (nfsargsp->wsize > NFS_MAXDGRAMDATA)
+ nfsargsp->wsize = NFS_MAXDGRAMDATA;
+ }
+}
+
+char *
+getnfsargs(spec, nfsargsp)
+ char *spec;
+ struct nfs_args *nfsargsp;
+{
+ register CLIENT *clp;
+ struct hostent *hp;
+ static struct sockaddr_in saddr;
+ struct timeval pertry, try;
+ enum clnt_stat clnt_stat;
+ int so = RPC_ANYSOCK;
+ char *fsp, *hostp, *delimp;
+ u_short tport;
+ static struct nfhret nfhret;
+ static char nam[MNAMELEN + 1];
+ char buf[MAXPATHLEN + 1];
+
+ strncpy(buf, spec, MAXPATHLEN);
+ buf[MAXPATHLEN] = '\0';
+ strncpy(nam, spec, MNAMELEN);
+ nam[MNAMELEN] = '\0';
+ if ((delimp = index(buf, '@')) != NULL) {
+ hostp = delimp + 1;
+ fsp = buf;
+ } else if ((delimp = index(buf, ':')) != NULL) {
+ hostp = buf;
+ fsp = delimp + 1;
+ } else {
+ (void) fprintf(stderr,
+ "mount: No <host>:<dirpath> or <dirpath>@<host> spec\n");
+ return (0);
+ }
+ *delimp = '\0';
+ if ((hp = gethostbyname(hostp)) == NULL) {
+ (void) fprintf(stderr, "mount: Can't get net id for host\n");
+ return (0);
+ }
+ bcopy(hp->h_addr, (caddr_t)&saddr.sin_addr, hp->h_length);
+ nfhret.stat = ETIMEDOUT; /* Mark not yet successful */
+ while (retrycnt > 0) {
+ saddr.sin_family = AF_INET;
+ saddr.sin_port = htons(PMAPPORT);
+ if ((tport = pmap_getport(&saddr, RPCPROG_NFS,
+ NFS_VER2, IPPROTO_UDP)) == 0) {
+ if ((opflags & ISBGRND) == 0)
+ clnt_pcreateerror("NFS Portmap");
+ } else {
+ saddr.sin_port = 0;
+ pertry.tv_sec = 10;
+ pertry.tv_usec = 0;
+ if ((clp = clntudp_create(&saddr, RPCPROG_MNT,
+ RPCMNT_VER1, pertry, &so)) == NULL) {
+ if ((opflags & ISBGRND) == 0)
+ clnt_pcreateerror("Cannot MNT PRC");
+ } else {
+ clp->cl_auth = authunix_create_default();
+ try.tv_sec = 10;
+ try.tv_usec = 0;
+ clnt_stat = clnt_call(clp, RPCMNT_MOUNT,
+ xdr_dir, fsp, xdr_fh, &nfhret, try);
+ if (clnt_stat != RPC_SUCCESS) {
+ if ((opflags & ISBGRND) == 0)
+ clnt_perror(clp, "Bad MNT RPC");
+ } else {
+ auth_destroy(clp->cl_auth);
+ clnt_destroy(clp);
+ retrycnt = 0;
+ }