BSD 4_3_Net_2 release
[unix-history] / usr / src / sbin / mount / mount.c
index 71d1656..9c561b2 100644 (file)
@@ -2,17 +2,33 @@
  * 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, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *     This product includes software developed by the University of
+ *     California, Berkeley and its contributors.
+ * 4. 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 BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
  */
 
 #ifndef lint
  */
 
 #ifndef lint
@@ -22,19 +38,15 @@ char copyright[] =
 #endif /* not lint */
 
 #ifndef lint
 #endif /* not lint */
 
 #ifndef lint
-static char sccsid[] = "@(#)mount.c    5.31 (Berkeley) %G%";
+static char sccsid[] = "@(#)mount.c    5.44 (Berkeley) 2/26/91";
 #endif /* not lint */
 
 #endif /* not lint */
 
-#include "pathnames.h"
 #include <sys/param.h>
 #include <sys/file.h>
 #include <sys/time.h>
 #include <sys/wait.h>
 #include <sys/param.h>
 #include <sys/file.h>
 #include <sys/time.h>
 #include <sys/wait.h>
-#include <fstab.h>
-#include <errno.h>
-#include <stdio.h>
-#include <signal.h>
-#include <strings.h>
+#include <sys/errno.h>
+#include <sys/signal.h>
 #include <sys/mount.h>
 #ifdef NFS
 #include <sys/socket.h>
 #include <sys/mount.h>
 #ifdef NFS
 #include <sys/socket.h>
@@ -47,6 +59,11 @@ static char sccsid[] = "@(#)mount.c  5.31 (Berkeley) %G%";
 #include <nfs/nfsv2.h>
 #include <nfs/nfs.h>
 #endif
 #include <nfs/nfsv2.h>
 #include <nfs/nfs.h>
 #endif
+#include <fstab.h>
+#include <string.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include "pathnames.h"
 
 #define DEFAULT_ROOTUID        -2
 
 
 #define DEFAULT_ROOTUID        -2
 
@@ -59,12 +76,15 @@ static char sccsid[] = "@(#)mount.c 5.31 (Berkeley) %G%";
 int fake, verbose, updateflg, mnttype;
 char *mntname, **envp;
 char **vfslist, **makevfslist();
 int fake, verbose, updateflg, mnttype;
 char *mntname, **envp;
 char **vfslist, **makevfslist();
+static void prmount();
 
 #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,
@@ -93,7 +113,6 @@ 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, ret, pid, i;
        long mntsize;
        struct statfs *mntbuf, *getmntpt();
        int all, ch, rval, flags, ret, pid, i;
        long mntsize;
        struct statfs *mntbuf, *getmntpt();
@@ -117,7 +136,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;
@@ -151,7 +170,7 @@ main(argc, argv, arge)
                                continue;
                        /* `/' is special, it's always mounted */
                        if (!strcmp(fs->fs_file, "/"))
                                continue;
                        /* `/' 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);
@@ -165,7 +184,7 @@ main(argc, argv, arge)
                if (verbose || fake || type)
                        usage();
                if ((mntsize = getmntinfo(&mntbuf, MNT_NOWAIT)) == 0) {
                if (verbose || fake || type)
                        usage();
                if ((mntsize = getmntinfo(&mntbuf, MNT_NOWAIT)) == 0) {
-                       fprintf(stderr,
+                       (void) fprintf(stderr,
                                "mount: cannot get mount information\n");
                        exit(1);
                }
                                "mount: cannot get mount information\n");
                        exit(1);
                }
@@ -180,7 +199,7 @@ main(argc, argv, arge)
 
        if (argc == 1 && updateflg) {
                if ((mntbuf = getmntpt(*argv)) == NULL) {
 
        if (argc == 1 && updateflg) {
                if ((mntbuf = getmntpt(*argv)) == NULL) {
-                       fprintf(stderr,
+                       (void) fprintf(stderr,
                            "mount: unknown special file or file system %s.\n",
                            *argv);
                        exit(1);
                            "mount: unknown special file or file system %s.\n",
                            *argv);
                        exit(1);
@@ -191,16 +210,16 @@ main(argc, argv, arge)
                        strcpy(mntbuf->f_mntfromname, fs->fs_spec);
                }
                ret = mountfs(mntbuf->f_mntfromname, mntbuf->f_mntonname,
                        strcpy(mntbuf->f_mntfromname, fs->fs_spec);
                }
                ret = mountfs(mntbuf->f_mntfromname, mntbuf->f_mntonname,
-                   updateflg, type, options, NULL);
+                   updateflg, type, options, (char *)NULL);
        } else if (argc == 1) {
                if (!(fs = getfsfile(*argv)) && !(fs = getfsspec(*argv))) {
        } else if (argc == 1) {
                if (!(fs = getfsfile(*argv)) && !(fs = getfsspec(*argv))) {
-                       fprintf(stderr,
+                       (void) fprintf(stderr,
                            "mount: unknown special file or file system %s.\n",
                            *argv);
                        exit(1);
                }
                if (BADTYPE(fs->fs_type)) {
                            "mount: unknown special file or file system %s.\n",
                            *argv);
                        exit(1);
                }
                if (BADTYPE(fs->fs_type)) {
-                       fprintf(stderr,
+                       (void) fprintf(stderr,
                            "mount: %s has unknown file system type.\n", *argv);
                        exit(1);
                }
                            "mount: %s has unknown file system type.\n", *argv);
                        exit(1);
                }
@@ -211,7 +230,16 @@ main(argc, argv, arge)
                usage();
                ret = 1;
        } else {
                usage();
                ret = 1;
        } else {
-               ret = mountfs(argv[0], argv[1], updateflg, type, options, NULL);
+               /*
+                * 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;
        }
        if ((pidfile = fopen(_PATH_MOUNTDPID, "r")) != NULL) {
                pid = 0;
@@ -227,13 +255,15 @@ mountfs(spec, name, flags, type, options, mntopts)
        char *spec, *name, *type, *options, *mntopts;
        int flags;
 {
        char *spec, *name, *type, *options, *mntopts;
        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)
@@ -248,8 +278,8 @@ mountfs(spec, name, flags, type, options, mntopts)
                        getufsopts(options, &flags);
                args.fspec = spec;
                args.exroot = DEFAULT_ROOTUID;
                        getufsopts(options, &flags);
                args.fspec = spec;
                args.exroot = DEFAULT_ROOTUID;
-               if (flags & M_RDONLY)
-                       args.exflags = M_EXRDONLY;
+               if (flags & MNT_RDONLY)
+                       args.exflags = MNT_EXRDONLY;
                else
                        args.exflags = 0;
                argp = (caddr_t)&args;
                else
                        args.exflags = 0;
                argp = (caddr_t)&args;
@@ -262,7 +292,7 @@ mountfs(spec, name, flags, type, options, mntopts)
                        getnfsopts(mntopts, &nfsargs, &opflags, &retrycnt);
                if (options)
                        getnfsopts(options, &nfsargs, &opflags, &retrycnt);
                        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 */
@@ -285,19 +315,19 @@ mountfs(spec, name, flags, type, options, mntopts)
                argv[argc++] = NULL;
                sprintf(execname, "%s/mount_%s", _PATH_EXECDIR, mntname);
                if (verbose) {
                argv[argc++] = NULL;
                sprintf(execname, "%s/mount_%s", _PATH_EXECDIR, mntname);
                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, (int *)&status, 0) != -1 &&
                            WIFEXITED(status) &&
                            WEXITSTATUS(status) != 0)
                                return (WEXITSTATUS(status));
                            WIFEXITED(status) &&
                            WEXITSTATUS(status) != 0)
                                return (WEXITSTATUS(status));
@@ -305,9 +335,9 @@ mountfs(spec, name, flags, type, options, mntopts)
                        goto out;
                }
                execve(execname, argv, envp);
                        goto out;
                }
                execve(execname, argv, envp);
-               fprintf(stderr, "mount: cannot exec %s for %s: ",
+               (void) fprintf(stderr, "mount: cannot exec %s for %s: ",
                        execname, name);
                        execname, name);
-               perror("");
+               perror((char *)NULL);
                exit (1);
                /* NOTREACHED */
 
                exit (1);
                /* NOTREACHED */
 
@@ -315,20 +345,19 @@ mountfs(spec, name, flags, type, options, mntopts)
        if (!fake && mount(mnttype, name, flags, argp)) {
                if (opflags & ISBGRND)
                        exit(1);
        if (!fake && mount(mnttype, name, flags, argp)) {
                if (opflags & ISBGRND)
                        exit(1);
-               fprintf(stderr, "%s on %s: ", spec, name);
+               (void) fprintf(stderr, "%s on %s: ", spec, name);
                switch (errno) {
                case EMFILE:
                switch (errno) {
                case EMFILE:
-                       fprintf(stderr, "Mount table full\n");
+                       (void) fprintf(stderr, "Mount table full\n");
                        break;
                case EINVAL:
                        break;
                case EINVAL:
-                       if (flags & M_UPDATE)
-                               fprintf(stderr, "Specified device does %s\n",
-                                       "not match mounted device");
+                       if (flags & MNT_UPDATE)
+                               (void) fprintf(stderr, "Specified device %s\n",
+                                       "does not match mounted device");
+                       else if (mnttype == MOUNT_UFS)
+                               (void) fprintf(stderr, "Bogus super block\n");
                        else
                        else
-                               fprintf(stderr, "Bogus super block\n");
-                       break;
-               case EOPNOTSUPP:
-                       fprintf(stderr, "Operation not supported\n");
+                               perror((char *)NULL);
                        break;
                default:
                        perror((char *)NULL);
                        break;
                default:
                        perror((char *)NULL);
@@ -342,33 +371,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
+static void
 prmount(spec, name, flags)
        char *spec, *name;
 prmount(spec, name, flags)
        char *spec, *name;
-       long flags;
+       register short flags;
 {
 {
+       register int first;
 
        if (opflags & ISBGRND)
                return;
 
        if (opflags & ISBGRND)
                return;
-       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)
@@ -388,7 +430,8 @@ getmnttype(fstype)
 usage()
 {
 
 usage()
 {
 
-       fprintf(stderr, "usage:\n  mount %s %s\n  mount %s\n  mount %s\n",
+       (void) 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 ] [ -t nfs | ufs | external_type ]",
                "[ -o options ] special node",
                "[ -afrwu ] [ -t nfs | ufs | external_type ]",
@@ -398,14 +441,14 @@ usage()
 
 getstdopts(options, flagp)
        char *options;
 
 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;
@@ -413,49 +456,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;
 }
 
@@ -465,9 +508,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;
@@ -499,7 +541,7 @@ getmntpt(name)
 static int skipvfs;
 
 badvfstype(vfstype, vfslist)
 static int skipvfs;
 
 badvfstype(vfstype, vfslist)
-       long vfstype;
+       short vfstype;
        char **vfslist;
 {
 
        char **vfslist;
 {
 
@@ -534,7 +576,6 @@ makevfslist(fslist)
 {
        register char **av, *nextcp;
        register int i;
 {
        register char **av, *nextcp;
        register int i;
-       char *malloc();
 
        if (fslist == NULL)
                return (NULL);
 
        if (fslist == NULL)
                return (NULL);
@@ -545,7 +586,7 @@ makevfslist(fslist)
        for (i = 0, nextcp = fslist; *nextcp; nextcp++)
                if (*nextcp == ',')
                        i++;
        for (i = 0, nextcp = fslist; *nextcp; nextcp++)
                if (*nextcp == ',')
                        i++;
-       av = (char **)malloc((i+2) * sizeof(char *));
+       av = (char **)malloc((size_t)(i+2) * sizeof(char *));
        if (av == NULL)
                return (NULL);
        nextcp = fslist;
        if (av == NULL)
                return (NULL);
        nextcp = fslist;
@@ -560,13 +601,22 @@ makevfslist(fslist)
 }
 
 #ifdef NFS
 }
 
 #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;
 /*
  * Handle the getoption arg.
  * Essentially update "opflags", "retrycnt" and "nfsargs"
  */
 getnfsopts(optarg, nfsargsp, opflagsp, retrycntp)
        char *optarg;
-       struct nfs_args *nfsargsp;
+       register struct nfs_args *nfsargsp;
        int *opflagsp;
        int *retrycntp;
 {
        int *opflagsp;
        int *retrycntp;
 {
@@ -574,8 +624,7 @@ getnfsopts(optarg, nfsargsp, opflagsp, retrycntp)
        int num;
        char *nump;
 
        int num;
        char *nump;
 
-       cp = optarg;
-       while (cp != NULL && *cp != '\0') {
+       for (cp = optarg; cp != NULL && *cp != '\0'; cp = nextcp) {
                if ((nextcp = index(cp, ',')) != NULL)
                        *nextcp++ = '\0';
                if ((nump = index(cp, '=')) != NULL) {
                if ((nextcp = index(cp, ',')) != NULL)
                        *nextcp++ = '\0';
                if ((nump = index(cp, '=')) != NULL) {
@@ -589,9 +638,21 @@ 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)
+                               exclusive("soft, spongy");
                        nfsargsp->flags |= NFSMNT_SOFT;
                        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, "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) {
@@ -607,45 +668,54 @@ getnfsopts(optarg, nfsargsp, opflagsp, retrycntp)
                        nfsargsp->retrans = num;
                        nfsargsp->flags |= NFSMNT_RETRANS;
                }
                        nfsargsp->retrans = num;
                        nfsargsp->flags |= NFSMNT_RETRANS;
                }
-               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;
        static struct sockaddr_in saddr;
        struct timeval pertry, try;
        enum clnt_stat clnt_stat;
        int so = RPC_ANYSOCK;
        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 *hostp, *delimp;
+       char *fsp, *hostp, *delimp;
        u_short tport;
        static struct nfhret nfhret;
        static char nam[MNAMELEN + 1];
        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';
        strncpy(nam, spec, MNAMELEN);
        nam[MNAMELEN] = '\0';
-       if ((delimp = index(spec, '@')) != NULL) {
+       if ((delimp = index(buf, '@')) != NULL) {
                hostp = delimp + 1;
                hostp = delimp + 1;
-       } else if ((delimp = index(spec, ':')) != NULL) {
-               hostp = spec;
-               spec = delimp + 1;
+               fsp = buf;
+       } else if ((delimp = index(buf, ':')) != NULL) {
+               hostp = buf;
+               fsp = delimp + 1;
        } else {
        } else {
-               fprintf(stderr,
-                   "No <host>:<dirpath> or <dirpath>@<host> spec\n");
+               (void) fprintf(stderr,
+                   "mount: No <host>:<dirpath> or <dirpath>@<host> spec\n");
                return (0);
        }
        *delimp = '\0';
        if ((hp = gethostbyname(hostp)) == NULL) {
                return (0);
        }
        *delimp = '\0';
        if ((hp = gethostbyname(hostp)) == NULL) {
-               fprintf(stderr, "Can't get net id for host\n");
+               (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);
                return (0);
        }
        bcopy(hp->h_addr, (caddr_t)&saddr.sin_addr, hp->h_length);
-       nfhret.stat = EACCES;   /* Mark not yet successful */
+       nfhret.stat = ETIMEDOUT;        /* Mark not yet successful */
        while (retrycnt > 0) {
                saddr.sin_family = AF_INET;
                saddr.sin_port = htons(PMAPPORT);
        while (retrycnt > 0) {
                saddr.sin_family = AF_INET;
                saddr.sin_port = htons(PMAPPORT);
@@ -666,7 +736,7 @@ getnfsargs(spec)
                                try.tv_sec = 10;
                                try.tv_usec = 0;
                                clnt_stat = clnt_call(clp, RPCMNT_MOUNT,
                                try.tv_sec = 10;
                                try.tv_usec = 0;
                                clnt_stat = clnt_call(clp, RPCMNT_MOUNT,
-                                   xdr_dir, spec, xdr_fh, &nfhret, try);
+                                   xdr_dir, fsp, xdr_fh, &nfhret, try);
                                if (clnt_stat != RPC_SUCCESS) {
                                        if ((opflags & ISBGRND) == 0)
                                                clnt_perror(clp, "Bad MNT RPC");
                                if (clnt_stat != RPC_SUCCESS) {
                                        if ((opflags & ISBGRND) == 0)
                                                clnt_perror(clp, "Bad MNT RPC");
@@ -691,16 +761,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: ", spec);
+               (void) fprintf(stderr, "Mount RPC error on %s: ", spec);
                errno = nfhret.stat;
                errno = nfhret.stat;
-               perror(NULL);
+               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);
 }
 
 /*
 }
 
 /*