Subject: bin/298: mount_nfs cannot parse args in fstab
To: None <gnats-admin>
From: None <arndt@mailhost.uni-koblenz.de>
List: netbsd-bugs
Date: 06/21/1994 00:05:02
>Number:         298
>Category:       bin
>Synopsis:       mount_nfs cannot parse args in fstab and -o
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    gnats-admin (Utility Bug People)
>State:          open
>Class:          change-request
>Submitter-Id:   net
>Arrival-Date:   Tue Jun 21 00:05:01 1994
>Originator:     Uwe Arndt
>Organization:
Uwe Arndt                              | arndt@uniko.uni-koblenz.de
Universitaet Koblenz,                  |
Rechenzentrum                          | Voice: +49 261 9119-642
Rheinau 1, D-56075 Koblenz, Germany    | Fax:   +49 261 9119-499
>Release:        
>Environment:
	
System: NetBSD harvey.uni-koblenz.de 0.9C NetBSD 0.9C (HARVEY) #0: Mon Jun 20 09:51:39 MET DST 1994 root@harvey.uni-koblenz.de:/usr/src/sys/arch/i386/compile/HARVEY i386


>Description:
	Putting options for nfs in an fstab entry gives an error message and
	the mount is skipped.
>How-To-Repeat:
	infko:/var/mail	/var/mail       nfs     rw,soft,bg,intr 0 0 
>Fix:
	I've put getnfsopts (taken from old mount) in mount_nfs. The following
	gives me the functionality I need and can be a framework to support
	all eventual special nfs options.


*** mount_nfs.c.orig	Mon Jun 20 17:24:21 1994
--- mount_nfs.c		Tue Jun 21 08:35:19 1994
***************
*** 137,142 ****
--- 137,144 ----
  int	xdr_dir __P((XDR *, char *));
  int	xdr_fh __P((XDR *, struct nfhret *));
  
+ int	getnfsopts __P((char *, struct nfs_args *, int *, int *, int *));
+ 
  int
  main(argc, argv)
  	int argc;
***************
*** 229,235 ****
  			break;
  #endif
  		case 'o':
! 			getmntopts(optarg, mopts, &mntflags);
  			break;
  		case 'P':
  			nfsargsp->flags |= NFSMNT_RESVPORT;
--- 231,238 ----
  			break;
  #endif
  		case 'o':
! 			getnfsopts(optarg, nfsargsp, &opflags, &retrycnt, 
! 				&mntflags);
  			break;
  		case 'P':
  			nfsargsp->flags |= NFSMNT_RESVPORT;
***************
*** 348,353 ****
--- 351,422 ----
  		}
  	}
  	exit(0);
+ }
+ 
+ /*
+  * Handle the getoption arg.
+  * Essentially update "opflags", "retrycnt" and "nfsargs"
+  * all unknown options are passed to getmntopts
+  */
+ getnfsopts(optarg, nfsargsp, opflagsp, retrycntp, mntflagsp)
+ 	char *optarg;
+ 	register struct nfs_args *nfsargsp;
+ 	int *opflagsp;
+ 	int *retrycntp;
+ 	int *mntflagsp;
+ {
+ 	register char *cp, *nextcp;
+ 	int num;
+ 	char *nump;
+ 	char *cmntopt;
+ 
+ 	for (cp = optarg; cp != NULL && *cp != '\0'; cp = nextcp) {
+ 		if ((nextcp = index(cp, ',')) != NULL)
+ 			*nextcp++ = '\0';
+ 		cmntopt = strdup(cp);		/* copy for getmntopts */
+ 		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")) {
+ 			nfsargsp->flags |= NFSMNT_SOFT;
+ 		} 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;
+ 		}
+ 		else
+ 			getmntopts(cmntopt, mopts, mntflagsp);
+ 		free(cmntopt);
+ 	}
+ 	if (nfsargsp->sotype == SOCK_DGRAM) {
+ 		if (nfsargsp->rsize > NFS_MAXDGRAMDATA)
+ 			nfsargsp->rsize = NFS_MAXDGRAMDATA;
+ 		if (nfsargsp->wsize > NFS_MAXDGRAMDATA)
+ 			nfsargsp->wsize = NFS_MAXDGRAMDATA;
+ 	}
  }
  
  int

>Audit-Trail:
>Unformatted:


------------------------------------------------------------------------------