BSD 4_3_Reno release
[unix-history] / usr / src / sbin / mount / mount.c
index b00ee74..f3456c7 100644 (file)
@@ -2,17 +2,19 @@
  * Copyright (c) 1980, 1989 The Regents of the University of California.
  * All rights reserved.
  *
  * Copyright (c) 1980, 1989 The Regents of the University of California.
  * All rights reserved.
  *
- * Redistribution and use in source and binary forms are permitted
- * provided that the above copyright notice and this paragraph are
- * duplicated in all such forms and that any documentation,
- * advertising materials, and other materials related to such
- * distribution and use acknowledge that the software was developed
- * by the University of California, Berkeley.  The name of the
- * University may not be used to endorse or promote products derived
- * from this software without specific prior written permission.
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+ * Redistribution and use in source and binary forms are permitted provided
+ * that: (1) source distributions retain this entire copyright notice and
+ * comment, and (2) distributions including binaries display the following
+ * acknowledgement:  ``This product includes software developed by the
+ * University of California, Berkeley and its contributors'' in the
+ * documentation or other materials provided with the distribution and in
+ * all advertising materials mentioning features or use of this software.
+ * Neither the name of the University nor the names of its contributors may
+ * be used to endorse or promote products derived from this software without
+ * specific prior written permission.
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  */
 
 #ifndef lint
  */
 
 #ifndef lint
@@ -22,7 +24,7 @@ char copyright[] =
 #endif /* not lint */
 
 #ifndef lint
 #endif /* not lint */
 
 #ifndef lint
-static char sccsid[] = "@(#)mount.c    5.17 (Berkeley) %G%";
+static char sccsid[] = "@(#)mount.c    5.39 (Berkeley) 6/22/90";
 #endif /* not lint */
 
 #include "pathnames.h"
 #endif /* not lint */
 
 #include "pathnames.h"
@@ -33,10 +35,8 @@ static char sccsid[] = "@(#)mount.c  5.17 (Berkeley) %G%";
 #include <fstab.h>
 #include <errno.h>
 #include <stdio.h>
 #include <fstab.h>
 #include <errno.h>
 #include <stdio.h>
-#include <strings.h>
-#include <sys/dir.h>
-#include <sys/uio.h>
-#include <sys/namei.h>
+#include <signal.h>
+#include <string.h>
 #include <sys/mount.h>
 #ifdef NFS
 #include <sys/socket.h>
 #include <sys/mount.h>
 #ifdef NFS
 #include <sys/socket.h>
@@ -50,6 +50,8 @@ static char sccsid[] = "@(#)mount.c   5.17 (Berkeley) %G%";
 #include <nfs/nfs.h>
 #endif
 
 #include <nfs/nfs.h>
 #endif
 
+#define DEFAULT_ROOTUID        -2
+
 #define        BADTYPE(type) \
        (strcmp(type, FSTAB_RO) && strcmp(type, FSTAB_RW) && \
            strcmp(type, FSTAB_RQ))
 #define        BADTYPE(type) \
        (strcmp(type, FSTAB_RO) && strcmp(type, FSTAB_RW) && \
            strcmp(type, FSTAB_RQ))
@@ -58,12 +60,15 @@ static char sccsid[] = "@(#)mount.c 5.17 (Berkeley) %G%";
 
 int fake, verbose, updateflg, mnttype;
 char *mntname, **envp;
 
 int fake, verbose, updateflg, mnttype;
 char *mntname, **envp;
+char **vfslist, **makevfslist();
 
 #ifdef NFS
 int xdr_dir(), xdr_fh();
 char *getnfsargs();
 
 #ifdef NFS
 int xdr_dir(), xdr_fh();
 char *getnfsargs();
-struct nfs_args nfsargs = {
-       (struct sockaddr_in *)0,
+struct nfs_args nfsdefargs = {
+       (struct sockaddr *)0,
+       SOCK_DGRAM,
+       0,
        (nfsv2fh_t *)0,
        0,
        NFS_WSIZE,
        (nfsv2fh_t *)0,
        0,
        NFS_WSIZE,
@@ -77,7 +82,8 @@ struct nfhret {
        u_long  stat;
        nfsv2fh_t nfh;
 };
        u_long  stat;
        nfsv2fh_t nfh;
 };
-int retrycnt = 10000;
+#define        DEF_RETRY       10000
+int retrycnt;
 #define        BGRND   1
 #define        ISBGRND 2
 int opflags = 0;
 #define        BGRND   1
 #define        ISBGRND 2
 int opflags = 0;
@@ -91,11 +97,11 @@ main(argc, argv, arge)
        extern char *optarg;
        extern int optind;
        register struct fstab *fs;
        extern char *optarg;
        extern int optind;
        register struct fstab *fs;
-       register int cnt;
-       int all, ch, rval, flags, i;
+       int all, ch, rval, flags, ret, pid, i;
        long mntsize;
        long mntsize;
-       struct statfs *mntbuf;
+       struct statfs *mntbuf, *getmntpt();
        char *type, *options = NULL;
        char *type, *options = NULL;
+       FILE *pidfile;
 
        envp = arge;
        all = 0;
 
        envp = arge;
        all = 0;
@@ -114,7 +120,7 @@ main(argc, argv, arge)
                        type = FSTAB_RO;
                        break;
                case 'u':
                        type = FSTAB_RO;
                        break;
                case 'u':
-                       updateflg = M_UPDATE;
+                       updateflg = MNT_UPDATE;
                        break;
                case 'v':
                        verbose = 1;
                        break;
                case 'v':
                        verbose = 1;
@@ -126,6 +132,7 @@ main(argc, argv, arge)
                        options = optarg;
                        break;
                case 't':
                        options = optarg;
                        break;
                case 't':
+                       vfslist = makevfslist(optarg);
                        mnttype = getmnttype(optarg);
                        break;
                case '?':
                        mnttype = getmnttype(optarg);
                        break;
                case '?':
@@ -143,9 +150,11 @@ main(argc, argv, arge)
                while (fs = getfsent()) {
                        if (BADTYPE(fs->fs_type))
                                continue;
                while (fs = getfsent()) {
                        if (BADTYPE(fs->fs_type))
                                continue;
+                       if (badvfsname(fs->fs_vfstype, vfslist))
+                               continue;
                        /* `/' is special, it's always mounted */
                        if (!strcmp(fs->fs_file, "/"))
                        /* `/' is special, it's always mounted */
                        if (!strcmp(fs->fs_file, "/"))
-                               flags = M_UPDATE;
+                               flags = MNT_UPDATE;
                        else
                                flags = updateflg;
                        mnttype = getmnttype(fs->fs_vfstype);
                        else
                                flags = updateflg;
                        mnttype = getmnttype(fs->fs_vfstype);
@@ -158,18 +167,35 @@ main(argc, argv, arge)
        if (argc == 0) {
                if (verbose || fake || type)
                        usage();
        if (argc == 0) {
                if (verbose || fake || type)
                        usage();
-               if ((mntsize = getmntinfo(&mntbuf)) == 0) {
+               if ((mntsize = getmntinfo(&mntbuf, MNT_NOWAIT)) == 0) {
                        fprintf(stderr,
                                "mount: cannot get mount information\n");
                        exit(1);
                }
                        fprintf(stderr,
                                "mount: cannot get mount information\n");
                        exit(1);
                }
-               for (i = 0; i < mntsize; i++)
+               for (i = 0; i < mntsize; i++) {
+                       if (badvfstype(mntbuf[i].f_type, vfslist))
+                               continue;
                        prmount(mntbuf[i].f_mntfromname, mntbuf[i].f_mntonname,
                                mntbuf[i].f_flags);
                        prmount(mntbuf[i].f_mntfromname, mntbuf[i].f_mntonname,
                                mntbuf[i].f_flags);
+               }
                exit(0);
        }
 
                exit(0);
        }
 
-       if (argc == 1) {
+       if (argc == 1 && updateflg) {
+               if ((mntbuf = getmntpt(*argv)) == NULL) {
+                       fprintf(stderr,
+                           "mount: unknown special file or file system %s.\n",
+                           *argv);
+                       exit(1);
+               }
+               mnttype = mntbuf->f_type;
+               if (!strcmp(mntbuf->f_mntfromname, "root_device")) {
+                       fs = getfsfile("/");
+                       strcpy(mntbuf->f_mntfromname, fs->fs_spec);
+               }
+               ret = mountfs(mntbuf->f_mntfromname, mntbuf->f_mntonname,
+                   updateflg, type, options, (char *)NULL);
+       } else if (argc == 1) {
                if (!(fs = getfsfile(*argv)) && !(fs = getfsspec(*argv))) {
                        fprintf(stderr,
                            "mount: unknown special file or file system %s.\n",
                if (!(fs = getfsfile(*argv)) && !(fs = getfsspec(*argv))) {
                        fprintf(stderr,
                            "mount: unknown special file or file system %s.\n",
@@ -182,14 +208,31 @@ main(argc, argv, arge)
                        exit(1);
                }
                mnttype = getmnttype(fs->fs_vfstype);
                        exit(1);
                }
                mnttype = getmnttype(fs->fs_vfstype);
-               exit(mountfs(fs->fs_spec, fs->fs_file, updateflg,
-                   type, options, fs->fs_mntops));
-       }
-
-       if (argc != 2)
+               ret = mountfs(fs->fs_spec, fs->fs_file, updateflg,
+                   type, options, fs->fs_mntops);
+       } else if (argc != 2) {
                usage();
                usage();
-
-       exit(mountfs(argv[0], argv[1], updateflg, type, options, NULL));
+               ret = 1;
+       } else {
+               /*
+                * If -t flag has not been specified, and spec
+                * contains either a ':' or a '@' then assume that
+                * an NFS filesystem is being specified ala Sun.
+                */
+               if (vfslist == (char **)0 &&
+                   (index(argv[0], ':') || index(argv[0], '@')))
+                       mnttype = MOUNT_NFS;
+               ret = mountfs(argv[0], argv[1], updateflg, type, options,
+                   (char *)NULL);
+       }
+       if ((pidfile = fopen(_PATH_MOUNTDPID, "r")) != NULL) {
+               pid = 0;
+               fscanf(pidfile, "%d", &pid);
+               fclose(pidfile);
+               if (pid > 0)
+                       kill(pid, SIGHUP);
+       }
+       exit (ret);
 }
 
 mountfs(spec, name, flags, type, options, mntopts)
 }
 
 mountfs(spec, name, flags, type, options, mntopts)
@@ -197,12 +240,15 @@ mountfs(spec, name, flags, type, options, mntopts)
        int flags;
 {
        extern int errno;
        int flags;
 {
        extern int errno;
-       register int cnt;
-       int argc, status, i;
+       union wait status;
+       pid_t pid;
+       int argc, i;
        struct ufs_args args;
        struct ufs_args args;
+       struct nfs_args nfsargs;
        char *argp, *argv[50];
        char execname[MAXPATHLEN + 1], flagval[12];
 
        char *argp, *argv[50];
        char execname[MAXPATHLEN + 1], flagval[12];
 
+       nfsargs = nfsdefargs;
        if (mntopts)
                getstdopts(mntopts, &flags);
        if (options)
        if (mntopts)
                getstdopts(mntopts, &flags);
        if (options)
@@ -216,16 +262,22 @@ mountfs(spec, name, flags, type, options, mntopts)
                if (options)
                        getufsopts(options, &flags);
                args.fspec = spec;
                if (options)
                        getufsopts(options, &flags);
                args.fspec = spec;
+               args.exroot = DEFAULT_ROOTUID;
+               if (flags & MNT_RDONLY)
+                       args.exflags = MNT_EXRDONLY;
+               else
+                       args.exflags = 0;
                argp = (caddr_t)&args;
                break;
 
 #ifdef NFS
        case MOUNT_NFS:
                argp = (caddr_t)&args;
                break;
 
 #ifdef NFS
        case MOUNT_NFS:
+               retrycnt = DEF_RETRY;
                if (mntopts)
                        getnfsopts(mntopts, &nfsargs, &opflags, &retrycnt);
                if (options)
                        getnfsopts(options, &nfsargs, &opflags, &retrycnt);
                if (mntopts)
                        getnfsopts(mntopts, &nfsargs, &opflags, &retrycnt);
                if (options)
                        getnfsopts(options, &nfsargs, &opflags, &retrycnt);
-               if (argp = getnfsargs(spec, name, type))
+               if (argp = getnfsargs(spec, &nfsargs))
                        break;
                return (1);
 #endif /* NFS */
                        break;
                return (1);
 #endif /* NFS */
@@ -245,21 +297,22 @@ mountfs(spec, name, flags, type, options, mntopts)
                        argc += getexecopts(options, &argv[argc]);
                argv[argc++] = spec;
                argv[argc++] = name;
                        argc += getexecopts(options, &argv[argc]);
                argv[argc++] = spec;
                argv[argc++] = name;
-               sprintf(execname, "%s/%s", _PATH_EXECDIR, mntname);
+               argv[argc++] = NULL;
+               sprintf(execname, "%s/mount_%s", _PATH_EXECDIR, mntname);
                if (verbose) {
                if (verbose) {
-                       printf("exec: %s", execname);
-                       for (i = 1; i < argc; i++)
-                               printf(" %s", argv[i]);
-                       printf("\n");
+                       (void)printf("exec: %s", execname);
+                       for (i = 1; i < argc - 1; i++)
+                               (void)printf(" %s", argv[i]);
+                       (void)printf("\n");
                }
                if (fake)
                        break;
                }
                if (fake)
                        break;
-               if (i = vfork()) {
-                       if (i == -1) {
+               if (pid = vfork()) {
+                       if (pid == -1) {
                                perror("mount: vfork starting file system");
                                return (1);
                        }
                                perror("mount: vfork starting file system");
                                return (1);
                        }
-                       if (waitpid(i, &status, 0) != -1 &&
+                       if (waitpid(pid, &status, 0) != -1 &&
                            WIFEXITED(status) &&
                            WEXITSTATUS(status) != 0)
                                return (WEXITSTATUS(status));
                            WIFEXITED(status) &&
                            WEXITSTATUS(status) != 0)
                                return (WEXITSTATUS(status));
@@ -267,7 +320,9 @@ mountfs(spec, name, flags, type, options, mntopts)
                        goto out;
                }
                execve(execname, argv, envp);
                        goto out;
                }
                execve(execname, argv, envp);
-               perror(execname);
+               fprintf(stderr, "mount: cannot exec %s for %s: ",
+                       execname, name);
+               perror((char *)NULL);
                exit (1);
                /* NOTREACHED */
 
                exit (1);
                /* NOTREACHED */
 
@@ -281,7 +336,7 @@ mountfs(spec, name, flags, type, options, mntopts)
                        fprintf(stderr, "Mount table full\n");
                        break;
                case EINVAL:
                        fprintf(stderr, "Mount table full\n");
                        break;
                case EINVAL:
-                       if (flags & M_UPDATE)
+                       if (flags & MNT_UPDATE)
                                fprintf(stderr, "Specified device does %s\n",
                                        "not match mounted device");
                        else
                                fprintf(stderr, "Specified device does %s\n",
                                        "not match mounted device");
                        else
@@ -302,42 +357,46 @@ out:
                prmount(spec, name, flags);
 
        if (opflags & ISBGRND)
                prmount(spec, name, flags);
 
        if (opflags & ISBGRND)
-               exit();
-       else
-               return(0);
+               exit(1);
+       return(0);
 }
 
 static
 prmount(spec, name, flags)
        char *spec, *name;
 }
 
 static
 prmount(spec, name, flags)
        char *spec, *name;
-       long flags;
+       register short flags;
 {
 {
-       register char *root;
+       register int first;
 
        if (opflags & ISBGRND)
                return;
 
        if (opflags & ISBGRND)
                return;
-       /*
-        * trim trailing /'s and find last component of name
-        */
-       for (root = index(spec, '\0'); *--root == '/';)
-               /* void */;
-       *++root = '\0';
-       if (root = rindex(spec, '/'))
-               spec = root + 1;
-       printf("%s on %s", spec, name);
-       if (flags & M_RDONLY)
-               printf(" (read-only)");
-       if (flags & M_NOEXEC)
-               printf(" (noexec)");
-       if (flags & M_NOSUID)
-               printf(" (nosuid)");
-       if (flags & M_NODEV)
-               printf(" (nodev)");
-       if (flags & M_SYNCHRONOUS)
-               printf(" (synchronous)");
-       if (flags & M_UPDATE)
-               printf(" (update only)");
-       printf("\n");
+       (void)printf("%s on %s", spec, name);
+       if (!(flags & MNT_VISFLAGMASK)) {
+               (void)printf("\n");
+               return;
+       }
+       first = 0;
+#define        PR(msg) (void)printf("%s%s", !first++ ? " (" : ", ", msg)
+       if (flags & MNT_RDONLY)
+               PR("read-only");
+       if (flags & MNT_NOEXEC)
+               PR("noexec");
+       if (flags & MNT_NOSUID)
+               PR("nosuid");
+       if (flags & MNT_NODEV)
+               PR("nodev");
+       if (flags & MNT_SYNCHRONOUS)
+               PR("synchronous");
+       if (flags & MNT_QUOTA)
+               PR("with quotas");
+       if (flags & MNT_LOCAL)
+               PR("local");
+       if (flags & MNT_EXPORTED)
+               if (flags & MNT_EXRDONLY)
+                       PR("NFS exported read-only");
+               else
+                       PR("NFS exported");
+       (void)printf(")\n");
 }
 
 getmnttype(fstype)
 }
 
 getmnttype(fstype)
@@ -356,20 +415,25 @@ getmnttype(fstype)
 
 usage()
 {
 
 usage()
 {
-       fprintf(stderr, "usage: mount [-afurw]\nor mount [-furw] special | node\nor mount [-furw] special node\n");
+
+       fprintf(stderr, "usage:\n  mount %s %s\n  mount %s\n  mount %s\n",
+               "[ -frwu ] [ -t nfs | ufs | external_type ]",
+               "[ -o options ] special node",
+               "[ -afrwu ] [ -t nfs | ufs | external_type ]",
+               "[ -frwu ] special | node");
        exit(1);
 }
 
 getstdopts(options, flagp)
        char *options;
        exit(1);
 }
 
 getstdopts(options, flagp)
        char *options;
-       long *flagp;
+       int *flagp;
 {
        register char *opt;
        int negative;
 {
        register char *opt;
        int negative;
-       char *optbuf[BUFSIZ], *strtok();
+       char optbuf[BUFSIZ];
 
 
-       strcpy(optbuf, options);
-       for (opt = strtok(optbuf, ","); opt; opt = strtok(NULL, ",")) {
+       (void)strcpy(optbuf, options);
+       for (opt = strtok(optbuf, ","); opt; opt = strtok((char *)NULL, ",")) {
                if (opt[0] == 'n' && opt[1] == 'o') {
                        negative++;
                        opt += 2;
                if (opt[0] == 'n' && opt[1] == 'o') {
                        negative++;
                        opt += 2;
@@ -377,49 +441,49 @@ getstdopts(options, flagp)
                        negative = 0;
                }
                if (!negative && !strcasecmp(opt, FSTAB_RO)) {
                        negative = 0;
                }
                if (!negative && !strcasecmp(opt, FSTAB_RO)) {
-                       *flagp |= M_RDONLY;
+                       *flagp |= MNT_RDONLY;
                        continue;
                }
                if (!negative && !strcasecmp(opt, FSTAB_RW)) {
                        continue;
                }
                if (!negative && !strcasecmp(opt, FSTAB_RW)) {
-                       *flagp &= ~M_RDONLY;
+                       *flagp &= ~MNT_RDONLY;
                        continue;
                }
                if (!strcasecmp(opt, "exec")) {
                        if (negative)
                        continue;
                }
                if (!strcasecmp(opt, "exec")) {
                        if (negative)
-                               *flagp |= M_NOEXEC;
+                               *flagp |= MNT_NOEXEC;
                        else
                        else
-                               *flagp &= ~M_NOEXEC;
+                               *flagp &= ~MNT_NOEXEC;
                        continue;
                }
                if (!strcasecmp(opt, "suid")) {
                        if (negative)
                        continue;
                }
                if (!strcasecmp(opt, "suid")) {
                        if (negative)
-                               *flagp |= M_NOSUID;
+                               *flagp |= MNT_NOSUID;
                        else
                        else
-                               *flagp &= ~M_NOSUID;
+                               *flagp &= ~MNT_NOSUID;
                        continue;
                }
                if (!strcasecmp(opt, "dev")) {
                        if (negative)
                        continue;
                }
                if (!strcasecmp(opt, "dev")) {
                        if (negative)
-                               *flagp |= M_NODEV;
+                               *flagp |= MNT_NODEV;
                        else
                        else
-                               *flagp &= ~M_NODEV;
+                               *flagp &= ~MNT_NODEV;
                        continue;
                }
                if (!strcasecmp(opt, "synchronous")) {
                        if (!negative)
                        continue;
                }
                if (!strcasecmp(opt, "synchronous")) {
                        if (!negative)
-                               *flagp |= M_SYNCHRONOUS;
+                               *flagp |= MNT_SYNCHRONOUS;
                        else
                        else
-                               *flagp &= ~M_SYNCHRONOUS;
+                               *flagp &= ~MNT_SYNCHRONOUS;
                        continue;
                }
        }
 }
 
                        continue;
                }
        }
 }
 
+/* ARGSUSED */
 getufsopts(options, flagp)
        char *options;
 getufsopts(options, flagp)
        char *options;
-       long *flagp;
+       int *flagp;
 {
 {
-
        return;
 }
 
        return;
 }
 
@@ -429,9 +493,8 @@ getexecopts(options, argv)
 {
        register int argc = 0;
        register char *opt;
 {
        register int argc = 0;
        register char *opt;
-       char *strtok();
 
 
-       for (opt = strtok(options, ","); opt; opt = strtok(NULL, ",")) {
+       for (opt = strtok(options, ","); opt; opt = strtok((char *)NULL, ",")) {
                if (opt[0] != '-')
                        continue;
                argv[argc++] = opt;
                if (opt[0] != '-')
                        continue;
                argv[argc++] = opt;
@@ -443,6 +506,85 @@ getexecopts(options, argv)
        return (argc);
 }
 
        return (argc);
 }
 
+struct statfs *
+getmntpt(name)
+       char *name;
+{
+       long mntsize;
+       register long i;
+       struct statfs *mntbuf;
+
+       mntsize = getmntinfo(&mntbuf, MNT_NOWAIT);
+       for (i = 0; i < mntsize; i++) {
+               if (!strcmp(mntbuf[i].f_mntfromname, name) ||
+                   !strcmp(mntbuf[i].f_mntonname, name))
+                       return (&mntbuf[i]);
+       }
+       return ((struct statfs *)0);
+}
+
+static int skipvfs;
+
+badvfstype(vfstype, vfslist)
+       short vfstype;
+       char **vfslist;
+{
+
+       if (vfslist == 0)
+               return(0);
+       while (*vfslist) {
+               if (vfstype == getmnttype(*vfslist))
+                       return(skipvfs);
+               vfslist++;
+       }
+       return (!skipvfs);
+}
+
+badvfsname(vfsname, vfslist)
+       char *vfsname;
+       char **vfslist;
+{
+
+       if (vfslist == 0)
+               return(0);
+       while (*vfslist) {
+               if (strcmp(vfsname, *vfslist) == 0)
+                       return(skipvfs);
+               vfslist++;
+       }
+       return (!skipvfs);
+}
+
+char **
+makevfslist(fslist)
+       char *fslist;
+{
+       register char **av, *nextcp;
+       register int i;
+
+       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
 /*
  * Handle the getoption arg.
 #ifdef NFS
 /*
  * Handle the getoption arg.
@@ -473,9 +615,25 @@ getnfsopts(optarg, nfsargsp, opflagsp, retrycntp)
                if (!strcmp(cp, "bg")) {
                        *opflagsp |= BGRND;
                } else if (!strcmp(cp, "soft")) {
                if (!strcmp(cp, "bg")) {
                        *opflagsp |= BGRND;
                } else if (!strcmp(cp, "soft")) {
+                       if (nfsargsp->flags & NFSMNT_SPONGY) {
+                               fprintf(stderr,
+                                       "Options soft, spongy mutually exclusive\n");
+                               exit(1);
+                       }
                        nfsargsp->flags |= NFSMNT_SOFT;
                        nfsargsp->flags |= NFSMNT_SOFT;
+               } else if (!strcmp(cp, "spongy")) {
+                       if (nfsargsp->flags & NFSMNT_SOFT) {
+                               fprintf(stderr,
+                                       "Options soft, spongy mutually exclusive\n");
+                               exit(1);
+                       }
+                       nfsargsp->flags |= NFSMNT_SPONGY;
                } else if (!strcmp(cp, "intr")) {
                        nfsargsp->flags |= NFSMNT_INT;
                } 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) {
                } else if (!strcmp(cp, "retry") && num > 0) {
                        *retrycntp = num;
                } else if (!strcmp(cp, "rsize") && num > 0) {
@@ -493,22 +651,30 @@ getnfsopts(optarg, nfsargsp, opflagsp, retrycntp)
                }
                cp = nextcp;
        }
                }
                cp = nextcp;
        }
+       if (nfsargsp->sotype == SOCK_DGRAM) {
+               if (nfsargsp->rsize > NFS_MAXDGRAMDATA)
+                       nfsargsp->rsize = NFS_MAXDGRAMDATA;
+               if (nfsargsp->wsize > NFS_MAXDGRAMDATA)
+                       nfsargsp->wsize = NFS_MAXDGRAMDATA;
+       }
 }
 
 char *
 }
 
 char *
-getnfsargs(spec)
+getnfsargs(spec, nfsargsp)
        char *spec;
        char *spec;
+       struct nfs_args *nfsargsp;
 {
 {
+       extern int errno;
        register CLIENT *clp;
        struct hostent *hp;
        register CLIENT *clp;
        struct hostent *hp;
-       struct sockaddr_in saddr;
+       static struct sockaddr_in saddr;
        struct timeval pertry, try;
        enum clnt_stat clnt_stat;
        int so = RPC_ANYSOCK;
        char *hostp, *delimp;
        u_short tport;
        struct timeval pertry, try;
        enum clnt_stat clnt_stat;
        int so = RPC_ANYSOCK;
        char *hostp, *delimp;
        u_short tport;
-       struct nfhret nfhret;
-       char nam[MNAMELEN + 1];
+       static struct nfhret nfhret;
+       static char nam[MNAMELEN + 1];
 
        strncpy(nam, spec, MNAMELEN);
        nam[MNAMELEN] = '\0';
 
        strncpy(nam, spec, MNAMELEN);
        nam[MNAMELEN] = '\0';
@@ -574,15 +740,16 @@ getnfsargs(spec)
        if (nfhret.stat) {
                if (opflags & ISBGRND)
                        exit(1);
        if (nfhret.stat) {
                if (opflags & ISBGRND)
                        exit(1);
-               fprintf(stderr, "Can't access %s, errno=%d\n", spec,
-                   nfhret.stat);
+               fprintf(stderr, "Can't access %s: ", spec);
+               errno = nfhret.stat;
+               perror((char *)NULL);
                return (0);
        }
        saddr.sin_port = htons(tport);
                return (0);
        }
        saddr.sin_port = htons(tport);
-       nfsargs.addr = &saddr;
-       nfsargs.fh = &nfhret.nfh;
-       nfsargs.hostname = nam;
-       return ((caddr_t)&nfsargs);
+       nfsargsp->addr = (struct sockaddr *) &saddr;
+       nfsargsp->fh = &nfhret.nfh;
+       nfsargsp->hostname = nam;
+       return ((caddr_t)nfsargsp);
 }
 
 /*
 }
 
 /*