From owner-svn-src-user@FreeBSD.ORG Tue Nov 11 12:35:20 2008 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 714D5106567F; Tue, 11 Nov 2008 12:35:20 +0000 (UTC) (envelope-from dfr@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 51C7B8FC12; Tue, 11 Nov 2008 12:35:20 +0000 (UTC) (envelope-from dfr@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id mABCZKbm001856; Tue, 11 Nov 2008 12:35:20 GMT (envelope-from dfr@svn.freebsd.org) Received: (from dfr@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id mABCZKA9001854; Tue, 11 Nov 2008 12:35:20 GMT (envelope-from dfr@svn.freebsd.org) Message-Id: <200811111235.mABCZKA9001854@svn.freebsd.org> From: Doug Rabson Date: Tue, 11 Nov 2008 12:35:20 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r184843 - user/dfr/gssapi/6/sbin/mount_nfs X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 11 Nov 2008 12:35:20 -0000 Author: dfr Date: Tue Nov 11 12:35:20 2008 New Revision: 184843 URL: http://svn.freebsd.org/changeset/base/184843 Log: MFC: 164457-164458,164733,179308,183008,183182,184588 Add nmount and RPCSEC_GSS support. Modified: user/dfr/gssapi/6/sbin/mount_nfs/ (props changed) user/dfr/gssapi/6/sbin/mount_nfs/mount_nfs.8 user/dfr/gssapi/6/sbin/mount_nfs/mount_nfs.c Modified: user/dfr/gssapi/6/sbin/mount_nfs/mount_nfs.8 ============================================================================== --- user/dfr/gssapi/6/sbin/mount_nfs/mount_nfs.8 Tue Nov 11 12:25:08 2008 (r184842) +++ user/dfr/gssapi/6/sbin/mount_nfs/mount_nfs.8 Tue Nov 11 12:35:20 2008 (r184843) @@ -70,133 +70,23 @@ This behaviour is intended for file syst .Xr fstab 5 that are critical to the boot process. For non-critical file systems, the -.Fl b +.Cm bg and -.Fl R -flags provide mechanisms to prevent the boot process from hanging +.Cm retrycnt +options provide mechanisms to prevent the boot process from hanging if the server is unavailable. .Pp If the server becomes unresponsive while an NFS file system is mounted, any new or outstanding file operations on that file system will hang uninterruptibly until the server comes back. To modify this default behaviour, see the -.Fl i +.Cm intr and -.Fl s -flags. +.Cm soft +options. .Pp The options are: .Bl -tag -width indent -.It Fl 2 -Use the NFS Version 2 protocol (the default is to try version 3 first -then version 2). -Note that NFS version 2 has a file size limit of 2 gigabytes. -.It Fl 3 -Use the NFS Version 3 protocol. -.It Fl D -Set the -.Dq "dead server threshold" -to the specified number of round trip timeout intervals before a -.Dq "server not responding" -message is displayed. -.It Fl I -Set the readdir read size to the specified value. -The value should normally -be a multiple of -.Dv DIRBLKSIZ -that is <= the read size for the mount. -.It Fl L -Do -.Em not -forward -.Xr fcntl 2 -locks over the wire. -All locks will be local and not seen by the server -and likewise not seen by other NFS clients. -This removes the need to run the -.Xr rpcbind 8 -service and the -.Xr rpc.statd 8 -and -.Xr rpc.lockd 8 -servers on the client. -Note that this option will only be honored when performing the -initial mount, it will be silently ignored if used while updating -the mount options. -.It Fl N -Do -.Em not -use a reserved socket port number (see below). -.It Fl P -Use a reserved socket port number. -This flag is obsolete, and only retained for compatibility reasons. -Reserved port numbers are used by default now. -(For the rare case where the client has a trusted root account -but untrustworthy users and the network cables are in secure areas this does -help, but for normal desktop clients this does not apply.) -.It Fl R -Set the mount retry count to the specified value. -The default is a retry count of zero, which means to keep retrying -forever. -There is a 60 second delay between each attempt. -.It Fl T -Use TCP transport instead of UDP. -This is recommended for servers that are not on the same LAN cable as -the client. -Not all NFS servers support this method, especially older ones; -caution should be observed in these cases. -.It Fl U -Force the mount protocol to use UDP transport, even for TCP NFS mounts. -(Necessary for some old -.Bx -servers.) -.It Fl a -Set the read-ahead count to the specified value. -This may be in the range of 0 - 4, and determines how many blocks -will be read ahead when a large file is being read sequentially. -Trying a value greater than 1 for this is suggested for -mounts with a large bandwidth * delay product. -.It Fl b -If an initial attempt to contact the server fails, fork off a child to keep -trying the mount in the background. -Useful for -.Xr fstab 5 , -where the file system mount is not critical to multiuser operation. -.It Fl c -For UDP mount points, do not do a -.Xr connect 2 . -This must be used if the server does not reply to requests from the standard -NFS port number 2049 or replies to requests using a different IP address -(which can occur if the server is multi-homed). -Setting the -.Va vfs.nfs.nfs_ip_paranoia -sysctl to 0 will make this option the default. -.It Fl d -Turn off the dynamic retransmit timeout estimator. -This may be useful for UDP mounts that exhibit high retry rates, -since it is possible that the dynamically estimated timeout interval is too -short. -.It Fl g -Set the maximum size of the group list for the credentials to the -specified value. -This should be used for mounts on old servers that cannot handle a -group list size of 16, as specified in RFC 1057. -Try 8, if users in a lot of groups cannot get response from the mount -point. -.It Fl i -Make the mount interruptible, which implies that file system calls that -are delayed due to an unresponsive server will fail with EINTR when a -termination signal is posted for the process. -.It Fl l -Used with NQNFS and NFSV3 to specify that the \fBReaddirPlus\fR RPC should -be used. -This option reduces RPC traffic for cases such as -.Dq "ls -l" , -but tends to flood the attribute and name caches with prefetched entries. -Try this option and see whether performance improves or degrades. -Probably -most useful for client to server network interconnects with a large bandwidth -times delay product. .It Fl o Options are specified with a .Fl o @@ -206,9 +96,6 @@ See the man page for possible options and their meanings. The following NFS specific options are also available: .Bl -tag -width indent -.It Cm port Ns = Ns Aq Ar port_number -Use specified port number for NFS requests. -The default is to query the portmapper for the NFS port. .It Cm acregmin Ns = Ns Aq Ar seconds .It Cm acregmax Ns = Ns Aq Ar seconds .It Cm acdirmin Ns = Ns Aq Ar seconds @@ -225,6 +112,60 @@ for regular files, and 30 -> 60 seconds The algorithm to calculate the timeout is based on the age of the file. The older the file, the longer the cache is considered valid, subject to the limits above. +.It Cm bg +If an initial attempt to contact the server fails, fork off a child to keep +trying the mount in the background. +Useful for +.Xr fstab 5 , +where the file system mount is not critical to multiuser operation. +.It Cm deadthresh Ns = Ns Aq Ar value +Set the +.Dq "dead server threshold" +to the specified number of round trip timeout intervals before a +.Dq "server not responding" +message is displayed. +.It Cm dumbtimer +Turn off the dynamic retransmit timeout estimator. +This may be useful for UDP mounts that exhibit high retry rates, +since it is possible that the dynamically estimated timeout interval is too +short. +.It Cm fg +Same as not specifying +.Cm bg . +.It Cm hard +Same as not specifying +.Cm soft . +.It Cm intr +Make the mount interruptible, which implies that file system calls that +are delayed due to an unresponsive server will fail with EINTR when a +termination signal is posted for the process. +.It Cm maxgroups Ns = Ns Aq Ar value +Set the maximum size of the group list for the credentials to the +specified value. +This should be used for mounts on old servers that cannot handle a +group list size of 16, as specified in RFC 1057. +Try 8, if users in a lot of groups cannot get response from the mount +point. +.It Cm mntudp +Force the mount protocol to use UDP transport, even for TCP NFS mounts. +(Necessary for some old +.Bx +servers.) +.It Cm nfsv2 +Use the NFS Version 2 protocol (the default is to try version 3 first +then version 2). +Note that NFS version 2 has a file size limit of 2 gigabytes. +.It Cm nfsv3 +Use the NFS Version 3 protocol. +.It Cm noconn +For UDP mount points, do not do a +.Xr connect 2 . +This must be used if the server does not reply to requests from the standard +NFS port number 2049 or replies to requests using a different IP address +(which can occur if the server is multi-homed). +Setting the +.Va vfs.nfs.nfs_ip_paranoia +sysctl to 0 will make this option the default. .It Cm noinet4 , noinet6 Disables .Dv AF_INET @@ -233,58 +174,68 @@ or connections. Useful for hosts that have both an A record and an AAAA record for the same name. -.El -.Pp -.Sy Historic Fl o Sy Options -.Pp -Use of these options is deprecated, they are only mentioned here for -compatibility with historic versions of -.Nm . -.Bl -tag -width ".Cm dumbtimer" -.It Cm bg -Same as -.Fl b . -.It Cm fg -Same as not specifying -.Fl b . -.It Cm conn -Same as not specifying -.Fl c . -.It Cm dumbtimer -Same as -.Fl d . -.It Cm intr -Same as -.Fl i . -.It Cm lockd -Same as not specifying -.Fl L . -.It Cm nfsv2 -Same as -.Fl 2 . -.It Cm nfsv3 -Same as -.Fl 3 . +.It Cm nolockd +Do +.Em not +forward +.Xr fcntl 2 +locks over the wire. +All locks will be local and not seen by the server +and likewise not seen by other NFS clients. +This removes the need to run the +.Xr rpcbind 8 +service and the +.Xr rpc.statd 8 +and +.Xr rpc.lockd 8 +servers on the client. +Note that this option will only be honored when performing the +initial mount, it will be silently ignored if used while updating +the mount options. +.It Cm noresvport +Do +.Em not +use a reserved socket port number (see below). +.It Cm port Ns = Ns Aq Ar port_number +Use specified port number for NFS requests. +The default is to query the portmapper for the NFS port. .It Cm rdirplus -Same as -.Fl l . -.It Cm mntudp -Same as -.Fl U . +Used with NQNFS and NFSV3 to specify that the \fBReaddirPlus\fR RPC should +be used. +This option reduces RPC traffic for cases such as +.Dq "ls -l" , +but tends to flood the attribute and name caches with prefetched entries. +Try this option and see whether performance improves or degrades. +Probably +most useful for client to server network interconnects with a large bandwidth +times delay product. +.It Cm readahead Ns = Ns Aq Ar value +Set the read-ahead count to the specified value. +This may be in the range of 0 - 4, and determines how many blocks +will be read ahead when a large file is being read sequentially. +Trying a value greater than 1 for this is suggested for +mounts with a large bandwidth * delay product. +.It Cm readdirsize Ns = Ns Aq Ar value +Set the readdir read size to the specified value. +The value should normally +be a multiple of +.Dv DIRBLKSIZ +that is <= the read size for the mount. .It Cm resvport -Same as -.Fl P . -.It Cm soft -Same as -.Fl s . -.It Cm hard -Same as not specifying -.Fl s . -.It Cm tcp -Same as -.Fl T . -.El -.It Fl r +Use a reserved socket port number. +This flag is obsolete, and only retained for compatibility reasons. +Reserved port numbers are used by default now. +(For the rare case where the client has a trusted root account +but untrustworthy users and the network cables are in secure areas this does +help, but for normal desktop clients this does not apply.) +.It Cm retrans Ns = Ns Aq Ar value +Set the retransmit timeout count for soft mounts to the specified value. +.It Cm retrycnt Ns = Ns Aq Ar count +Set the mount retry count to the specified value. +The default is a retry count of zero, which means to keep retrying +forever. +There is a 60 second delay between each attempt. +.It Cm rsize Ns = Ns Aq Ar value Set the read data size to the specified value. It should normally be a power of 2 greater than or equal to 1024. This should be used for UDP mounts when the @@ -297,15 +248,18 @@ with the option to see what the .Dq "fragments dropped due to timeout" value is.) -See the -.Fl w -option as well. -.It Fl s +.It Cm soft A soft mount, which implies that file system calls will fail after .Ar retrycnt round trip timeout intervals. -.It Fl t +.It Cm tcp +Use TCP transport. +This is the default option, as it provides for increased reliability on both +LAN and WAN configurations compared to UDP. +Some old NFS servers do not support this method; UDP mounts may be required +for interoperability. +.It Cm timeout Ns = Ns Aq Ar value Set the initial retransmit timeout to the specified value. May be useful for fine tuning UDP mounts over internetworks with high packet loss rates or an overloaded server. @@ -314,25 +268,105 @@ Try increasing the interval if shows high retransmit rates while the file system is active or reducing the value if there is a low retransmit rate but long response delay observed. (Normally, the -.Fl d +.Cm dumbtimer option should be specified when using this option to manually tune the timeout interval.) -.It Fl w +.It Cm udp +Use UDP transport. +.It Cm wsize Ns = Ns Aq Ar value Set the write data size to the specified value. Ditto the comments w.r.t.\& the -.Fl r +.Cm rsize option, but using the .Dq "fragments dropped due to timeout" value on the server instead of the client. Note that both the -.Fl r +.Cm rsize and -.Fl w +.Cm wsize options should only be used as a last ditch effort at improving performance when mounting servers that do not support TCP mounts. +.El +.El +.Sh COMPATIBILITY +The following command line flags are equivalent to +.Fl o +named options and are supported for compatibility with older +installations. +.Bl -tag -width indent +.It Fl 2 +Same as +.Fl o Cm nfsv2 +.It Fl 3 +Same as +.Fl o Cm nfsv3 +.It Fl 4 +Same as +.Fl o Cm nfsv4 +.It Fl D +Same as +.Fl o Cm deadthresh +.It Fl I +Same as +.Fl o Cm readdirsize Ns = Ns Aq Ar value +.It Fl L +Same as +.Fl o Cm nolockd +.It Fl N +Same as +.Fl o Cm noresvport +.It Fl P +Use a reserved socket port number. +This flag is obsolete, and only retained for compatibility reasons. +(For the rare case where the client has a trusted root account +but untrustworthy users and the network cables are in secure areas this does +help, but for normal desktop clients this does not apply.) +.It Fl R +Same as +.Fl o Cm retrycnt Ns = Ns Aq Ar value +.It Fl T +Same as +.Fl o Cm tcp +.It Fl U +Same as +.Fl o Cm mntudp +.It Fl a +Same as +.Fl o Cm readahead Ns = Ns Aq Ar value +.It Fl b +Same as +.Fl o Cm bg +.It Fl c +Same as +.Fl o Cm noconn +.It Fl d +Same as +.Fl o Cm dumbtimer +.It Fl g +Same as +.Fl o Cm maxgroups +.It Fl i +Same as +.Fl o Cm intr +.It Fl l +Same as +.Fl o Cm rdirplus +.It Fl r +Same as +.Fl o Cm rsize Ns = Ns Aq Ar value +.It Fl s +Same as +.Fl o Cm soft +.It Fl t +Same as +.Fl o Cm retransmit Ns = Ns Aq Ar value +.It Fl w +Same as +.Fl o Cm wsize Ns = Ns Aq Ar value .It Fl x -Set the retransmit timeout count for soft mounts to the specified value. +Same as +.Fl o Cm retrans Ns = Ns Aq Ar value .El .Sh SEE ALSO .Xr mount 2 , Modified: user/dfr/gssapi/6/sbin/mount_nfs/mount_nfs.c ============================================================================== --- user/dfr/gssapi/6/sbin/mount_nfs/mount_nfs.c Tue Nov 11 12:25:08 2008 (r184842) +++ user/dfr/gssapi/6/sbin/mount_nfs/mount_nfs.c Tue Nov 11 12:35:20 2008 (r184843) @@ -49,6 +49,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include @@ -57,7 +58,6 @@ __FBSDID("$FreeBSD$"); #include #include #include -#include #include @@ -76,85 +76,9 @@ __FBSDID("$FreeBSD$"); #include "mntopts.h" #include "mounttab.h" -#define ALTF_BG 0x1 -#define ALTF_NOCONN 0x2 -#define ALTF_DUMBTIMR 0x4 -#define ALTF_INTR 0x8 -#define ALTF_NFSV3 0x20 -#define ALTF_RDIRPLUS 0x40 -#define ALTF_MNTUDP 0x80 -#define ALTF_RESVPORT 0x100 -#define ALTF_SEQPACKET 0x200 -#define ALTF_SOFT 0x800 -#define ALTF_TCP 0x1000 -#define ALTF_PORT 0x2000 -#define ALTF_NFSV2 0x4000 -#define ALTF_ACREGMIN 0x8000 -#define ALTF_ACREGMAX 0x10000 -#define ALTF_ACDIRMIN 0x20000 -#define ALTF_ACDIRMAX 0x40000 -#define ALTF_NOLOCKD 0x80000 -#define ALTF_NOINET4 0x100000 -#define ALTF_NOINET6 0x200000 - -struct mntopt mopts[] = { - MOPT_STDOPTS, - MOPT_FORCE, - MOPT_UPDATE, - MOPT_ASYNC, - { "bg", 0, ALTF_BG, 1 }, - { "fg", 1, ALTF_BG, 1 }, - { "conn", 1, ALTF_NOCONN, 1 }, - { "dumbtimer", 0, ALTF_DUMBTIMR, 1 }, - { "intr", 0, ALTF_INTR, 1 }, - { "nfsv3", 0, ALTF_NFSV3, 1 }, - { "rdirplus", 0, ALTF_RDIRPLUS, 1 }, - { "mntudp", 0, ALTF_MNTUDP, 1 }, - { "resvport", 0, ALTF_RESVPORT, 1 }, - { "soft", 0, ALTF_SOFT, 1 }, - { "hard", 1, ALTF_SOFT, 1 }, - { "tcp", 0, ALTF_TCP, 1 }, - { "port=", 0, ALTF_PORT, 1 }, - { "nfsv2", 0, ALTF_NFSV2, 1 }, - { "acregmin=", 0, ALTF_ACREGMIN, 1 }, - { "acregmax=", 0, ALTF_ACREGMAX, 1 }, - { "acdirmin=", 0, ALTF_ACDIRMIN, 1 }, - { "acdirmax=", 0, ALTF_ACDIRMAX, 1 }, - { "lockd", 1, ALTF_NOLOCKD, 1 }, - { "inet4", 1, ALTF_NOINET4, 1 }, - { "inet6", 1, ALTF_NOINET6, 1 }, - MOPT_END -}; - -struct nfs_args nfsdefargs = { - NFS_ARGSVERSION, - NULL, - sizeof (struct sockaddr_in), - SOCK_DGRAM, - 0, - NULL, - 0, - NFSMNT_RESVPORT, - NFS_WSIZE, - NFS_RSIZE, - NFS_READDIRSIZE, - 10, - NFS_RETRANS, - NFS_MAXGRPS, - NFS_DEFRAHEAD, - 0, /* was: NQ_DEFLEASE */ - NFS_MAXDEADTHRESH, /* was: NQ_DEADTHRESH */ - NULL, - /* args version 4 */ - NFS_MINATTRTIMO, - NFS_MAXATTRTIMO, - NFS_MINDIRATTRTIMO, - NFS_MAXDIRATTRTIMO, -}; - /* Table for af,sotype -> netid conversions. */ struct nc_protos { - char *netid; + const char *netid; int af; int sotype; } nc_protos[] = { @@ -162,7 +86,7 @@ struct nc_protos { {"tcp", AF_INET, SOCK_STREAM}, {"udp6", AF_INET6, SOCK_DGRAM}, {"tcp6", AF_INET6, SOCK_STREAM}, - {NULL} + {NULL, 0, 0} }; struct nfhret { @@ -180,7 +104,14 @@ int retrycnt = -1; int opflags = 0; int nfsproto = IPPROTO_UDP; int mnttcp_ok = 1; +int noconn = 0; char *portspec = NULL; /* Server nfs port; NULL means look up via rpcbind. */ +struct sockaddr *addr; +int addrlen = 0; +u_char *fh = NULL; +int fhsize = 0; +int secflavor = -1; + enum mountmode { ANY, V2, @@ -195,55 +126,20 @@ enum tryret { TRYRET_LOCALERR /* Local failure. */ }; -int getnfsargs(char *, struct nfs_args *); +int fallback_mount(struct iovec *iov, int iovlen, int mntflags); +int sec_name_to_num(char *sec); +char *sec_num_to_name(int num); +int getnfsargs(char *, struct iovec **iov, int *iovlen); /* void set_rpc_maxgrouplist(int); */ struct netconfig *getnetconf_cached(const char *netid); -char *netidbytype(int af, int sotype); +const char *netidbytype(int af, int sotype); void usage(void) __dead2; int xdr_dir(XDR *, char *); int xdr_fh(XDR *, struct nfhret *); -enum tryret nfs_tryproto(struct nfs_args *nfsargsp, struct addrinfo *ai, - char *hostp, char *spec, char **errstr); +enum tryret nfs_tryproto(struct addrinfo *ai, char *hostp, char *spec, + char **errstr, struct iovec **iov, int *iovlen); enum tryret returncode(enum clnt_stat stat, struct rpc_err *rpcerr); - -/* - * Used to set mount flags with getmntopts. Call with dir=TRUE to - * initialize altflags from the current mount flags. Call with - * dir=FALSE to update mount flags with the new value of altflags after - * the call to getmntopts. - */ -static void -set_flags(int* altflags, int* nfsflags, int dir) -{ -#define F2(af, nf) \ - if (dir) { \ - if (*nfsflags & NFSMNT_##nf) \ - *altflags |= ALTF_##af; \ - else \ - *altflags &= ~ALTF_##af; \ - } else { \ - if (*altflags & ALTF_##af) \ - *nfsflags |= NFSMNT_##nf; \ - else \ - *nfsflags &= ~NFSMNT_##nf; \ - } -#define F(f) F2(f,f) - - F(NOCONN); - F(DUMBTIMR); - F2(INTR, INT); - F(RDIRPLUS); - F(RESVPORT); - F(SOFT); - F(ACREGMIN); - F(ACREGMAX); - F(ACDIRMIN); - F(ACDIRMAX); - F(NOLOCKD); - -#undef F -#undef F2 -} +extern int getosreldate(void); int main(argc, argv) @@ -251,16 +147,23 @@ main(argc, argv) char *argv[]; { int c; - struct nfs_args *nfsargsp; - struct nfs_args nfsargs; - int mntflags, altflags, num; - char *name, *p, *spec; - char mntpath[MAXPATHLEN]; + struct iovec *iov; + int mntflags, num, iovlen; + int osversion; + char *name, *p, *spec, *fstype; + char mntpath[MAXPATHLEN], errmsg[255]; mntflags = 0; - altflags = 0; - nfsargs = nfsdefargs; - nfsargsp = &nfsargs; + iov = NULL; + iovlen = 0; + memset(errmsg, 0, sizeof(errmsg)); + + fstype = strrchr(argv[0], '_'); + if (fstype == NULL) + errx(EX_USAGE, "argv[0] must end in _fstype"); + + ++fstype; + while ((c = getopt(argc, argv, "23a:bcdD:g:I:iLlNo:PR:r:sTt:w:x:U")) != -1) switch (c) { @@ -271,168 +174,177 @@ main(argc, argv) mountmode = V3; break; case 'a': - num = strtol(optarg, &p, 10); - if (*p || num < 0) - errx(1, "illegal -a value -- %s", optarg); - nfsargsp->readahead = num; - nfsargsp->flags |= NFSMNT_READAHEAD; + printf("-a deprecated, use -o readhead=\n"); + build_iovec(&iov, &iovlen, "readahead", optarg, (size_t)-1); break; case 'b': opflags |= BGRND; break; case 'c': - nfsargsp->flags |= NFSMNT_NOCONN; + printf("-c deprecated, use -o noconn\n"); + build_iovec(&iov, &iovlen, "noconn", NULL, 0); + noconn = 1; break; case 'D': - num = strtol(optarg, &p, 10); - if (*p || num <= 0) - errx(1, "illegal -D value -- %s", optarg); - nfsargsp->deadthresh = num; - nfsargsp->flags |= NFSMNT_DEADTHRESH; + printf("-D deprecated, use -o deadthresh=\n"); + build_iovec(&iov, &iovlen, "deadthresh", optarg, (size_t)-1); break; case 'd': - nfsargsp->flags |= NFSMNT_DUMBTIMR; + printf("-d deprecated, use -o dumbtimer"); + build_iovec(&iov, &iovlen, "dumbtimer", NULL, 0); break; -#if 0 /* XXXX */ case 'g': + printf("-g deprecated, use -o maxgroups"); num = strtol(optarg, &p, 10); if (*p || num <= 0) errx(1, "illegal -g value -- %s", optarg); - set_rpc_maxgrouplist(num); - nfsargsp->maxgrouplist = num; - nfsargsp->flags |= NFSMNT_MAXGRPS; + //set_rpc_maxgrouplist(num); + build_iovec(&iov, &iovlen, "maxgroups", optarg, (size_t)-1); break; -#endif case 'I': - num = strtol(optarg, &p, 10); - if (*p || num <= 0) - errx(1, "illegal -I value -- %s", optarg); - nfsargsp->readdirsize = num; - nfsargsp->flags |= NFSMNT_READDIRSIZE; + printf("-I deprecated, use -o readdirsize=\n"); + build_iovec(&iov, &iovlen, "readdirsize", optarg, (size_t)-1); break; case 'i': - nfsargsp->flags |= NFSMNT_INT; + printf("-i deprecated, use -o intr\n"); + build_iovec(&iov, &iovlen, "intr", NULL, 0); break; case 'L': - nfsargsp->flags |= NFSMNT_NOLOCKD; + printf("-i deprecated, use -o nolockd\n"); + build_iovec(&iov, &iovlen, "nolockd", NULL, 0); break; case 'l': - nfsargsp->flags |= NFSMNT_RDIRPLUS; + printf("-l deprecated, -o rdirplus\n"); + build_iovec(&iov, &iovlen, "rdirplus", NULL, 0); break; case 'N': - nfsargsp->flags &= ~NFSMNT_RESVPORT; + printf("-N deprecated, do not specify -o resvport\n"); break; - case 'o': - altflags = 0; - set_flags(&altflags, &nfsargsp->flags, TRUE); - if (mountmode == V2) - altflags |= ALTF_NFSV2; - else if (mountmode == V3) - altflags |= ALTF_NFSV3; - getmntopts(optarg, mopts, &mntflags, &altflags); - set_flags(&altflags, &nfsargsp->flags, FALSE); - /* - * Handle altflags which don't map directly to - * mount flags. - */ - if (altflags & ALTF_BG) - opflags |= BGRND; - if (altflags & ALTF_NOINET4) - opflags |= OF_NOINET4; - if (altflags & ALTF_NOINET6) - opflags |= OF_NOINET6; - if (altflags & ALTF_MNTUDP) - mnttcp_ok = 0; - if (altflags & ALTF_TCP) { - nfsargsp->sotype = SOCK_STREAM; - nfsproto = IPPROTO_TCP; - } - if (altflags & ALTF_PORT) { - /* - * XXX Converting from a string to an int - * and back again is silly, and we should - * allow /etc/services names. - */ - p = strstr(optarg, "port="); - if (p) { + case 'o': { + int pass_flag_to_nmount; + char *opt = optarg; + while (opt) { + char *pval = NULL; + char *pnextopt = NULL; + char *val = ""; + pass_flag_to_nmount = 1; + pval = strchr(opt, '='); + pnextopt = strchr(opt, ','); + if (pval != NULL) { + *pval = '\0'; + val = pval + 1; + } + if (pnextopt) { + *pnextopt = '\0'; + pnextopt++; + } + if (strcmp(opt, "bg") == 0) { + opflags |= BGRND; + pass_flag_to_nmount=0; + } else if (strcmp(opt, "fg") == 0) { + /* same as not specifying -o bg */ + pass_flag_to_nmount=0; + } else if (strcmp(opt, "mntudp") == 0) { + mnttcp_ok = 0; + nfsproto = IPPROTO_UDP; + } else if (strcmp(opt, "udp") == 0) { + nfsproto = IPPROTO_UDP; + } else if (strcmp(opt, "tcp") == 0) { + nfsproto = IPPROTO_TCP; + } else if (strcmp(opt, "noinet4") == 0) { + pass_flag_to_nmount=0; + opflags |= OF_NOINET4; + } else if (strcmp(opt, "noinet6") == 0) { + pass_flag_to_nmount=0; + opflags |= OF_NOINET6; + } else if (strcmp(opt, "noconn") == 0) { + noconn = 1; + } else if (strcmp(opt, "nfsv2") == 0) { + pass_flag_to_nmount=0; + mountmode = V2; + } else if (strcmp(opt, "nfsv3") == 0) { + mountmode = V3; + } else if (strcmp(opt, "port") == 0) { + pass_flag_to_nmount=0; asprintf(&portspec, "%d", - atoi(p + 5)); + atoi(val)); if (portspec == NULL) err(1, "asprintf"); + } else if (strcmp(opt, "sec") == 0) { + /* + * Don't add this option to + * the iovec yet - we will + * negotiate which sec flavor + * to use with the remote + * mountd. + */ + pass_flag_to_nmount=0; + secflavor = sec_name_to_num(val); + if (secflavor < 0) { + errx(1, + "illegal sec value -- %s", + val); + } + } else if (strcmp(opt, "retrycnt") == 0) { + pass_flag_to_nmount=0; + num = strtol(val, &p, 10); + if (*p || num < 0) + errx(1, "illegal retrycnt value -- %s", val); + retrycnt = num; + } else if (strcmp(opt, "maxgroups") == 0) { + num = strtol(val, &p, 10); + if (*p || num <= 0) + errx(1, "illegal maxgroups value -- %s", val); + //set_rpc_maxgrouplist(num); } + if (pass_flag_to_nmount) + build_iovec(&iov, &iovlen, opt, val, + strlen(val) + 1); + opt = pnextopt; } - mountmode = ANY; - if (altflags & ALTF_NFSV2) - mountmode = V2; - if (altflags & ALTF_NFSV3) - mountmode = V3; - if (altflags & ALTF_ACREGMIN) { - p = strstr(optarg, "acregmin="); - if (p) - nfsargsp->acregmin = atoi(p + 9); - } - if (altflags & ALTF_ACREGMAX) { - p = strstr(optarg, "acregmax="); - if (p) - nfsargsp->acregmax = atoi(p + 9); - } - if (altflags & ALTF_ACDIRMIN) { - p = strstr(optarg, "acdirmin="); - if (p) - nfsargsp->acdirmin = atoi(p + 9); - } - if (altflags & ALTF_ACDIRMAX) { - p = strstr(optarg, "acdirmax="); - if (p) - nfsargsp->acdirmax = atoi(p + 9); } break; case 'P': - /* obsolete for NFSMNT_RESVPORT, now default */ + /* obsolete for -o noresvport now default */ + printf("-P deprecated, use -o noresvport\n"); + build_iovec(&iov, &iovlen, "noresvport", NULL, 0); break; case 'R': + printf("-R deprecated, use -o retrycnt=\n"); num = strtol(optarg, &p, 10); if (*p || num < 0) errx(1, "illegal -R value -- %s", optarg); retrycnt = num; break; case 'r': - num = strtol(optarg, &p, 10); - if (*p || num <= 0) - errx(1, "illegal -r value -- %s", optarg); - nfsargsp->rsize = num; - nfsargsp->flags |= NFSMNT_RSIZE; + printf("-r deprecated, use -o rsize=\n"); + build_iovec(&iov, &iovlen, "rsize", optarg, (size_t)-1); break; case 's': - nfsargsp->flags |= NFSMNT_SOFT; + printf("-s deprecated, use -o soft\n"); + build_iovec(&iov, &iovlen, "soft", NULL, 0); break; case 'T': - nfsargsp->sotype = SOCK_STREAM; nfsproto = IPPROTO_TCP; + printf("-T deprecated, use -o tcp\n"); break; case 't': - num = strtol(optarg, &p, 10); - if (*p || num <= 0) - errx(1, "illegal -t value -- %s", optarg); - nfsargsp->timeo = num; - nfsargsp->flags |= NFSMNT_TIMEO; + printf("-t deprecated, use -o timeout=\n"); + build_iovec(&iov, &iovlen, "timeout", optarg, (size_t)-1); break; case 'w': - num = strtol(optarg, &p, 10); - if (*p || num <= 0) - errx(1, "illegal -w value -- %s", optarg); - nfsargsp->wsize = num; - nfsargsp->flags |= NFSMNT_WSIZE; + printf("-w deprecated, use -o wsize=\n"); + build_iovec(&iov, &iovlen, "wsize", optarg, (size_t)-1); break; case 'x': - num = strtol(optarg, &p, 10); - if (*p || num <= 0) - errx(1, "illegal -x value -- %s", optarg); - nfsargsp->retrans = num; - nfsargsp->flags |= NFSMNT_RETRANS; + printf("-x deprecated, use -o retrans=\n"); + build_iovec(&iov, &iovlen, "retrans", optarg, (size_t)-1); break; case 'U': + printf("-U deprecated, use -o mntudp\n"); mnttcp_ok = 0; + nfsproto = IPPROTO_UDP; + build_iovec(&iov, &iovlen, "mntudp", NULL, 0); break; default: usage(); @@ -452,22 +364,280 @@ main(argc, argv) if (retrycnt == -1) /* The default is to keep retrying forever. */ retrycnt = 0; - if (!getnfsargs(spec, nfsargsp)) + + if (!getnfsargs(spec, &iov, &iovlen)) exit(1); /* resolve the mountpoint with realpath(3) */ (void)checkpath(name, mntpath); - if (mount("nfs", mntpath, mntflags, nfsargsp)) - err(1, "%s", mntpath); + build_iovec(&iov, &iovlen, "fstype", "nfs", (size_t)-1); + build_iovec(&iov, &iovlen, "fspath", mntpath, (size_t)-1); + build_iovec(&iov, &iovlen, "errmsg", errmsg, sizeof(errmsg)); + + /* + * XXX: + * Backwards compatibility routines for older kernels. + * Remove this and fallback_mount() code when we do not need to support *** DIFF OUTPUT TRUNCATED AT 1000 LINES ***