Author: trasz
Date: Thu Oct 30 08:05:51 2014
New Revision: 273848
URL: https://svnweb.freebsd.org/changeset/base/273848

Log:
  Get rid of obsolete code in mount_nfs(8).
  
  Reviewed by:  rmacklem@
  Sponsored by: The FreeBSD Foundation

Modified:
  head/sbin/mount_nfs/mount_nfs.c

Modified: head/sbin/mount_nfs/mount_nfs.c
==============================================================================
--- head/sbin/mount_nfs/mount_nfs.c     Thu Oct 30 08:04:48 2014        
(r273847)
+++ head/sbin/mount_nfs/mount_nfs.c     Thu Oct 30 08:05:51 2014        
(r273848)
@@ -130,7 +130,6 @@ enum tryret {
        TRYRET_LOCALERR         /* Local failure. */
 };
 
-static int     fallback_mount(struct iovec *iov, int iovlen);
 static int     sec_name_to_num(char *sec);
 static char    *sec_num_to_name(int num);
 static int     getnfsargs(char *, struct iovec **iov, int *iovlen);
@@ -150,7 +149,6 @@ main(int argc, char *argv[])
        int c;
        struct iovec *iov;
        int num, iovlen;
-       int osversion;
        char *name, *p, *spec, *fstype;
        char mntpath[MAXPATHLEN], errmsg[255];
        char hostname[MAXHOSTNAMELEN + 1], *gssname, gssn[MAXHOSTNAMELEN + 50];
@@ -443,21 +441,8 @@ main(int argc, char *argv[])
        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
-        * NFS mounts against older kernels which still need
-        * struct nfs_args to be passed in via nmount().
-        */
-       osversion = getosreldate();
-       if (osversion >= 702100) {
-               if (nmount(iov, iovlen, 0))
-                       err(1, "%s, %s", mntpath, errmsg);
-       } else {
-               if (fallback_mount(iov, iovlen))
-                       err(1, "%s, %s", mntpath, errmsg);
-       }
+       if (nmount(iov, iovlen, 0))
+               err(1, "%s, %s", mntpath, errmsg);
 
        exit(0);
 }
@@ -491,206 +476,6 @@ copyopt(struct iovec **newiov, int *newi
                build_iovec(newiov, newiovlen, name, value, len);
 }
 
-/*
- * XXX: This function is provided for backwards
- *      compatibility with older kernels which did not support
- *      passing NFS mount options to nmount() as individual
- *      parameters.  It should be eventually be removed.
- */
-static int
-fallback_mount(struct iovec *iov, int iovlen)
-{
-       struct nfs_args args = {
-           .version = NFS_ARGSVERSION,
-           .addr = NULL,
-           .addrlen = sizeof (struct sockaddr_in),
-           .sotype = SOCK_STREAM,
-           .proto = 0,
-           .fh = NULL,
-           .fhsize = 0,
-           .flags = NFSMNT_RESVPORT,
-           .wsize = NFS_WSIZE,
-           .rsize = NFS_RSIZE,
-           .readdirsize = NFS_READDIRSIZE,
-           .timeo = 10,
-           .retrans = NFS_RETRANS,
-           .maxgrouplist = NFS_MAXGRPS,
-           .readahead = NFS_DEFRAHEAD,
-           .wcommitsize = 0,                   /* was: NQ_DEFLEASE */
-           .deadthresh = NFS_MAXDEADTHRESH,    /* was: NQ_DEADTHRESH */
-           .hostname = NULL,
-           /* args version 4 */
-           .acregmin = NFS_MINATTRTIMO,
-           .acregmax = NFS_MAXATTRTIMO,
-           .acdirmin = NFS_MINDIRATTRTIMO,
-           .acdirmax = NFS_MAXDIRATTRTIMO,
-       };
-       int ret;
-       char *opt;
-       struct iovec *newiov;
-       int newiovlen;
-
-       if (findopt(iov, iovlen, "dumbtimer", NULL, NULL) == 0)
-               args.flags |= NFSMNT_DUMBTIMR;
-       if (findopt(iov, iovlen, "noconn", NULL, NULL) == 0)
-               args.flags |= NFSMNT_NOCONN;
-       if (findopt(iov, iovlen, "conn", NULL, NULL) == 0)
-               args.flags |= NFSMNT_NOCONN;
-       if (findopt(iov, iovlen, "nolockd", NULL, NULL) == 0)
-               args.flags |= NFSMNT_NOLOCKD;
-       if (findopt(iov, iovlen, "lockd", NULL, NULL) == 0)
-               args.flags &= ~NFSMNT_NOLOCKD;
-       if (findopt(iov, iovlen, "intr", NULL, NULL) == 0)
-               args.flags |= NFSMNT_INT;
-       if (findopt(iov, iovlen, "rdirplus", NULL, NULL) == 0)
-               args.flags |= NFSMNT_RDIRPLUS;
-       if (findopt(iov, iovlen, "resvport", NULL, NULL) == 0)
-               args.flags |= NFSMNT_RESVPORT;
-       if (findopt(iov, iovlen, "noresvport", NULL, NULL) == 0)
-               args.flags &= ~NFSMNT_RESVPORT;
-       if (findopt(iov, iovlen, "soft", NULL, NULL) == 0)
-               args.flags |= NFSMNT_SOFT;
-       if (findopt(iov, iovlen, "hard", NULL, NULL) == 0)
-               args.flags &= ~NFSMNT_SOFT;
-       if (findopt(iov, iovlen, "mntudp", NULL, NULL) == 0)
-               args.sotype = SOCK_DGRAM;
-       if (findopt(iov, iovlen, "udp", NULL, NULL) == 0)
-               args.sotype = SOCK_DGRAM;
-       if (findopt(iov, iovlen, "tcp", NULL, NULL) == 0)
-               args.sotype = SOCK_STREAM;
-       if (findopt(iov, iovlen, "nfsv3", NULL, NULL) == 0)
-               args.flags |= NFSMNT_NFSV3;
-       if (findopt(iov, iovlen, "readdirsize", &opt, NULL) == 0) {
-               if (opt == NULL) { 
-                       errx(1, "illegal readdirsize");
-               }
-               ret = sscanf(opt, "%d", &args.readdirsize);
-               if (ret != 1 || args.readdirsize <= 0) {
-                       errx(1, "illegal readdirsize: %s", opt);
-               }
-               args.flags |= NFSMNT_READDIRSIZE;
-       }
-       if (findopt(iov, iovlen, "readahead", &opt, NULL) == 0) {
-               if (opt == NULL) { 
-                       errx(1, "illegal readahead");
-               }
-               ret = sscanf(opt, "%d", &args.readahead);
-               if (ret != 1 || args.readahead <= 0) {
-                       errx(1, "illegal readahead: %s", opt);
-               }
-               args.flags |= NFSMNT_READAHEAD;
-       }
-       if (findopt(iov, iovlen, "wsize", &opt, NULL) == 0) {
-               if (opt == NULL) { 
-                       errx(1, "illegal wsize");
-               }
-               ret = sscanf(opt, "%d", &args.wsize);
-               if (ret != 1 || args.wsize <= 0) {
-                       errx(1, "illegal wsize: %s", opt);
-               }
-               args.flags |= NFSMNT_WSIZE;
-       }
-       if (findopt(iov, iovlen, "rsize", &opt, NULL) == 0) {
-               if (opt == NULL) { 
-                       errx(1, "illegal rsize");
-               }
-               ret = sscanf(opt, "%d", &args.rsize);
-               if (ret != 1 || args.rsize <= 0) {
-                       errx(1, "illegal wsize: %s", opt);
-               }
-               args.flags |= NFSMNT_RSIZE;
-       }
-       if (findopt(iov, iovlen, "retrans", &opt, NULL) == 0) {
-               if (opt == NULL) { 
-                       errx(1, "illegal retrans");
-               }
-               ret = sscanf(opt, "%d", &args.retrans);
-               if (ret != 1 || args.retrans <= 0) {
-                       errx(1, "illegal retrans: %s", opt);
-               }
-               args.flags |= NFSMNT_RETRANS;
-       }
-       if (findopt(iov, iovlen, "acregmin", &opt, NULL) == 0) {
-               ret = sscanf(opt, "%d", &args.acregmin);
-               if (ret != 1 || args.acregmin < 0) {
-                       errx(1, "illegal acregmin: %s", opt);
-               }
-               args.flags |= NFSMNT_ACREGMIN;
-       }
-       if (findopt(iov, iovlen, "acregmax", &opt, NULL) == 0) {
-               ret = sscanf(opt, "%d", &args.acregmax);
-               if (ret != 1 || args.acregmax < 0) {
-                       errx(1, "illegal acregmax: %s", opt);
-               }
-               args.flags |= NFSMNT_ACREGMAX;
-       }
-       if (findopt(iov, iovlen, "acdirmin", &opt, NULL) == 0) {
-               ret = sscanf(opt, "%d", &args.acdirmin);
-               if (ret != 1 || args.acdirmin < 0) {
-                       errx(1, "illegal acdirmin: %s", opt);
-               }
-               args.flags |= NFSMNT_ACDIRMIN;
-       }
-       if (findopt(iov, iovlen, "acdirmax", &opt, NULL) == 0) {
-               ret = sscanf(opt, "%d", &args.acdirmax);
-               if (ret != 1 || args.acdirmax < 0) {
-                       errx(1, "illegal acdirmax: %s", opt);
-               }
-               args.flags |= NFSMNT_ACDIRMAX;
-       }
-       if (findopt(iov, iovlen, "wcommitsize", &opt, NULL) == 0) {
-               ret = sscanf(opt, "%d", &args.wcommitsize);
-               if (ret != 1 || args.wcommitsize < 0) {
-                       errx(1, "illegal wcommitsize: %s", opt);
-               }
-               args.flags |= NFSMNT_WCOMMITSIZE;
-       }
-       if (findopt(iov, iovlen, "deadthresh", &opt, NULL) == 0) {
-               ret = sscanf(opt, "%d", &args.deadthresh);
-               if (ret != 1 || args.deadthresh <= 0) {
-                       errx(1, "illegal deadthresh: %s", opt);
-               }
-               args.flags |= NFSMNT_DEADTHRESH;
-       }
-       if (findopt(iov, iovlen, "timeout", &opt, NULL) == 0) {
-               ret = sscanf(opt, "%d", &args.timeo);
-               if (ret != 1 || args.timeo <= 0) {
-                       errx(1, "illegal timeout: %s", opt);
-               }
-               args.flags |= NFSMNT_TIMEO;
-       }
-       if (findopt(iov, iovlen, "maxgroups", &opt, NULL) == 0) {
-               ret = sscanf(opt, "%d", &args.maxgrouplist);
-               if (ret != 1 || args.timeo <= 0) {
-                       errx(1, "illegal maxgroups: %s", opt);
-               }
-               args.flags |= NFSMNT_MAXGRPS;
-       }
-       if (findopt(iov, iovlen, "addr", &opt,
-               &args.addrlen) == 0) {
-               args.addr = (struct sockaddr *) opt;
-       }
-       if (findopt(iov, iovlen, "fh", &opt, &args.fhsize) == 0) {
-               args.fh = opt;
-       }
-       if (findopt(iov, iovlen, "hostname", &args.hostname,
-               NULL) == 0) {
-       }
-       if (args.hostname == NULL) {
-               errx(1, "Invalid hostname");
-       }
-
-       newiov = NULL;
-       newiovlen = 0;
-
-       build_iovec(&newiov, &newiovlen, "nfs_args", &args, sizeof(args));
-       copyopt(&newiov, &newiovlen, iov, iovlen, "fstype");
-       copyopt(&newiov, &newiovlen, iov, iovlen, "fspath");
-       copyopt(&newiov, &newiovlen, iov, iovlen, "errmsg");
-
-       return nmount(newiov, newiovlen, 0);
-}
-
 static int
 sec_name_to_num(char *sec)
 {
_______________________________________________
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to