no newlines on err(3) calls; section 3 sets errno, too
[unix-history] / usr / src / sbin / mount / mount.c
index c3f62a6..6044ff9 100644 (file)
@@ -12,57 +12,61 @@ static char copyright[] =
 #endif /* not lint */
 
 #ifndef lint
 #endif /* not lint */
 
 #ifndef lint
-static char sccsid[] = "@(#)mount.c    8.6 (Berkeley) %G%";
+static char sccsid[] = "@(#)mount.c    8.11 (Berkeley) %G%";
 #endif /* not lint */
 
 #include <sys/param.h>
 #endif /* not lint */
 
 #include <sys/param.h>
-#include <sys/file.h>
-#include <sys/time.h>
 #include <sys/wait.h>
 #include <sys/wait.h>
-#include <sys/errno.h>
-#include <sys/signal.h>
-#include <sys/ucred.h>
 #include <sys/mount.h>
 #include <sys/mount.h>
+
+#include <err.h>
+#include <errno.h>
 #include <fstab.h>
 #include <fstab.h>
-#include <string.h>
+#include <signal.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <stdio.h>
 #include <stdlib.h>
-#include "pathnames.h"
-
-#define DEFAULT_ROOTUID        -2
+#include <string.h>
+#include <unistd.h>
 
 
-#define        BADTYPE(type) \
-       (strcmp(type, FSTAB_RO) && strcmp(type, FSTAB_RW) && \
-           strcmp(type, FSTAB_RQ))
-#define        SETTYPE(type) \
-       (!strcmp(type, FSTAB_RW) || !strcmp(type, FSTAB_RQ))
+#include "pathnames.h"
 
 
-int debug, force, verbose, updateflg, mnttype;
-char *mntname, **envp;
-char **vfslist, **makevfslist();
-static void prmount();
 
 
-main(argc, argv, arge)
+int debug, force, verbose, mnttype, skipvfs;
+char *mntname;
+
+int    badvfsname __P((char *, char **));
+int    badvfstype __P((int, char **));
+int    getexecopts __P((char *, char **));
+struct statfs
+      *getmntpt __P((char *));
+int    getmnttype __P((char *));
+void   getstdopts __P((char *, int *));
+void   getufsopts __P((char *, int *));
+char **makevfslist __P((char *));
+int    mountfs __P((char *, char *, int, char *, char *, char *));
+void   prmount __P((char *, char *, int));
+void   usage __P((void));
+
+int
+main(argc, argv)
        int argc;
        int argc;
-       char **argv;
-       char **arge;
+       char *argv[];
 {
 {
-       extern char *optarg;
-       extern int optind;
-       register struct fstab *fs;
-       int all, ch, rval, flags, ret, pid, i;
-       long mntsize;
-       struct statfs *mntbuf, *getmntpt();
-       char *type, *options = NULL;
+       struct fstab *fs;
+       struct statfs *mntbuf;
        FILE *pidfile;
        FILE *pidfile;
+       long mntsize;
+       int all, ch, i, pid, ret, rval, updateflg;
+       char *cp, *type, *options, **vfslist;
 
 
-       envp = arge;
-       all = 0;
-       type = NULL;
-       mnttype = MOUNT_UFS;
        mntname = "ufs";
        mntname = "ufs";
-       while ((ch = getopt(argc, argv, "adfrwuvt:o:")) != EOF)
-               switch((char)ch) {
+       mnttype = MOUNT_UFS;
+
+       all = updateflg = 0;
+       options = type = NULL;
+       vfslist = NULL;
+       while ((ch = getopt(argc, argv, "adfo:rwt:uv")) != EOF)
+               switch(ch) {
                case 'a':
                        all = 1;
                        break;
                case 'a':
                        all = 1;
                        break;
@@ -72,9 +76,16 @@ main(argc, argv, arge)
                case 'f':
                        force = 1;
                        break;
                case 'f':
                        force = 1;
                        break;
+               case 'o':
+                       options = optarg;
+                       break;
                case 'r':
                        type = FSTAB_RO;
                        break;
                case 'r':
                        type = FSTAB_RO;
                        break;
+               case 't':
+                       vfslist = makevfslist(optarg);
+                       mnttype = getmnttype(optarg);
+                       break;
                case 'u':
                        updateflg = MNT_UPDATE;
                        break;
                case 'u':
                        updateflg = MNT_UPDATE;
                        break;
@@ -84,13 +95,6 @@ main(argc, argv, arge)
                case 'w':
                        type = FSTAB_RW;
                        break;
                case 'w':
                        type = FSTAB_RW;
                        break;
-               case 'o':
-                       options = optarg;
-                       break;
-               case 't':
-                       vfslist = makevfslist(optarg);
-                       mnttype = getmnttype(optarg);
-                       break;
                case '?':
                default:
                        usage();
                case '?':
                default:
                        usage();
@@ -99,22 +103,20 @@ main(argc, argv, arge)
        argc -= optind;
        argv += optind;
 
        argc -= optind;
        argv += optind;
 
-       /* NOSTRICT */
+#define        BADTYPE(type)                                                   \
+       (strcmp(type, FSTAB_RO) &&                                      \
+           strcmp(type, FSTAB_RW) && strcmp(type, FSTAB_RQ))
 
        if (all) {
                rval = 0;
 
        if (all) {
                rval = 0;
-               while (fs = getfsent()) {
+               while ((fs = getfsent()) != NULL) {
                        if (BADTYPE(fs->fs_type))
                                continue;
                        if (badvfsname(fs->fs_vfstype, vfslist))
                                continue;
                        if (BADTYPE(fs->fs_type))
                                continue;
                        if (badvfsname(fs->fs_vfstype, vfslist))
                                continue;
-                       /* `/' is special, it's always mounted */
-                       if (!strcmp(fs->fs_file, "/"))
-                               flags = MNT_UPDATE;
-                       else
-                               flags = updateflg;
+                       /* `/' is special, it's always mounted. */
                        mnttype = getmnttype(fs->fs_vfstype);
                        mnttype = getmnttype(fs->fs_vfstype);
-                       rval |= mountfs(fs->fs_spec, fs->fs_file, flags,
+                       rval |= mountfs(fs->fs_spec, fs->fs_file, updateflg,
                            type, options, fs->fs_mntops);
                }
                exit(rval);
                            type, options, fs->fs_mntops);
                }
                exit(rval);
@@ -123,33 +125,27 @@ main(argc, argv, arge)
        if (argc == 0) {
                if (verbose || debug || type)
                        usage();
        if (argc == 0) {
                if (verbose || debug || type)
                        usage();
-               if ((mntsize = getmntinfo(&mntbuf, MNT_NOWAIT)) == 0) {
-                       (void) fprintf(stderr,
-                               "mount: cannot get mount information\n");
-                       exit(1);
-               }
+               if ((mntsize = getmntinfo(&mntbuf, MNT_NOWAIT)) == 0)
+                       err(1, "getmntinfo");
                for (i = 0; i < mntsize; i++) {
                        if (badvfstype(mntbuf[i].f_type, vfslist))
                                continue;
                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 && vfslist != NULL)
+               usage();
+
        if (argc == 1 && updateflg) {
        if (argc == 1 && updateflg) {
-               if ((mntbuf = getmntpt(*argv)) == NULL) {
-                       (void) fprintf(stderr,
-                           "mount: unknown special file or file system %s.\n",
-                           *argv);
-                       exit(1);
-               }
+               if ((mntbuf = getmntpt(*argv)) == NULL)
+                       errx(1,
+                           "unknown special file or file system %s.", *argv);
                mnttype = mntbuf->f_type;
                mnttype = mntbuf->f_type;
-               if ((fs = getfsfile(mntbuf->f_mntonname)) == NULL) {
-                       (void) fprintf(stderr,
-                           "mount: can't find fstab entry for %s.\n", *argv);
-                       exit(1);
-               }
+               if ((fs = getfsfile(mntbuf->f_mntonname)) == NULL)
+                       errx(1, "can't find fstab entry for %s.", *argv);
                mntname = fs->fs_vfstype;
 
                /*
                mntname = fs->fs_vfstype;
 
                /*
@@ -166,76 +162,66 @@ main(argc, argv, arge)
                if (options == NULL)
                        options = fs->fs_mntops;
                else {
                if (options == NULL)
                        options = fs->fs_mntops;
                else {
-                       register char *cp;
-
                        /*
                         * Concat the two strings with the command line
                         * options last so that they will override the
                         * fstab options.
                         */
                        i = strlen(fs->fs_mntops) + strlen(options) + 2;
                        /*
                         * Concat the two strings with the command line
                         * options last so that they will override the
                         * fstab options.
                         */
                        i = strlen(fs->fs_mntops) + strlen(options) + 2;
-                       if ((cp = malloc((size_t)i)) == NULL) {
-                               (void) fprintf(stderr,
-                                   "mount: -u malloc failed\n");
-                               exit(1);
-                       }
-                       sprintf(cp, "%s,%s", fs->fs_mntops, options);
+                       if ((cp = malloc((size_t)i)) == NULL)
+                               err(1, NULL);
+                       (void)snprintf(cp, i, "%s,%s", fs->fs_mntops, options);
                        options = cp;
                }
                        options = cp;
                }
-               ret = mountfs(fs->fs_spec, mntbuf->f_mntonname,
-                   updateflg, type, options, (char *)NULL);
+               ret = mountfs(fs->fs_spec,
+                   mntbuf->f_mntonname, updateflg, type, options, NULL);
        } else if (argc == 1) {
        } else if (argc == 1) {
-               if (!(fs = getfsfile(*argv)) && !(fs = getfsspec(*argv))) {
-                       (void) fprintf(stderr,
-                           "mount: unknown special file or file system %s.\n",
-                           *argv);
-                       exit(1);
-               }
-               if (BADTYPE(fs->fs_type)) {
-                       (void) fprintf(stderr,
-                           "mount: %s has unknown file system type.\n", *argv);
-                       exit(1);
-               }
+               if ((fs = getfsfile(*argv)) == NULL &&
+                   (fs = getfsspec(*argv)) == NULL)
+                       errx(1,
+                           "unknown special file or file system %s.", *argv);
+               if (BADTYPE(fs->fs_type))
+                       errx(1, "%s has unknown file system type.", *argv);
                mnttype = getmnttype(fs->fs_vfstype);
                mnttype = getmnttype(fs->fs_vfstype);
-               ret = mountfs(fs->fs_spec, fs->fs_file, updateflg,
-                   type, options, fs->fs_mntops);
+               ret = mountfs(fs->fs_spec,
+                   fs->fs_file, updateflg, type, options, fs->fs_mntops);
        } else if (argc != 2) {
                usage();
                ret = 1;
        } else {
                /*
        } else if (argc != 2) {
                usage();
                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 -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], '@'))) {
+               if (vfslist == NULL &&
+                   (strchr(argv[0], ':') || strchr(argv[0], '@'))) {
                        mnttype = MOUNT_NFS;
                        mntname = "nfs";
                }
                        mnttype = MOUNT_NFS;
                        mntname = "nfs";
                }
-               ret = mountfs(argv[0], argv[1], updateflg, type, options,
-                   (char *)NULL);
+               ret = mountfs(argv[0], argv[1], updateflg, type, options, NULL);
        }
        if ((pidfile = fopen(_PATH_MOUNTDPID, "r")) != NULL) {
                pid = 0;
        }
        if ((pidfile = fopen(_PATH_MOUNTDPID, "r")) != NULL) {
                pid = 0;
-               fscanf(pidfile, "%d", &pid);
-               fclose(pidfile);
-               if (pid > 0)
-                       kill(pid, SIGHUP);
+               (void)fscanf(pidfile, "%ld", &pid);
+               (void)fclose(pidfile);
+               if (pid > 0 && kill(pid, SIGHUP))
+                       err(1, "signal mountd");
        }
        }
-       exit (ret);
+
+       exit(ret);
 }
 
 }
 
+int
 mountfs(spec, name, flags, type, options, mntopts)
        char *spec, *name, *type, *options, *mntopts;
        int flags;
 {
 mountfs(spec, name, flags, type, options, mntopts)
        char *spec, *name, *type, *options, *mntopts;
        int flags;
 {
-       union wait status;
-       pid_t pid;
-       int argc, i;
        struct ufs_args args;
        struct ufs_args args;
+       pid_t pid;
+       int argc, i, status;
        char *argp, *argv[50];
        char *argp, *argv[50];
-       char execname[MAXPATHLEN + 1], flagval[12];
+       char execname[MAXPATHLEN + 1], flagval[12], mntpath[MAXPATHLEN];
 
        if (mntopts)
                getstdopts(mntopts, &flags);
 
        if (mntopts)
                getstdopts(mntopts, &flags);
@@ -245,6 +231,17 @@ mountfs(spec, name, flags, type, options, mntopts)
                getstdopts(type, &flags);
        if (force)
                flags |= MNT_FORCE;
                getstdopts(type, &flags);
        if (force)
                flags |= MNT_FORCE;
+
+       if (realpath(name, mntpath) == 0) {
+               warn("%s", mntpath);
+               return (1);
+       }
+
+       name = mntpath;
+
+       if (strcmp(name, "/") == 0)
+               flags |= MNT_UPDATE;
+
        switch (mnttype) {
        case MOUNT_UFS:
                if (mntopts)
        switch (mnttype) {
        case MOUNT_UFS:
                if (mntopts)
@@ -252,6 +249,7 @@ mountfs(spec, name, flags, type, options, mntopts)
                if (options)
                        getufsopts(options, &flags);
                args.fspec = spec;
                if (options)
                        getufsopts(options, &flags);
                args.fspec = spec;
+#define        DEFAULT_ROOTUID -2
                args.export.ex_root = DEFAULT_ROOTUID;
                if (flags & MNT_RDONLY)
                        args.export.ex_flags = MNT_EXRDONLY;
                args.export.ex_root = DEFAULT_ROOTUID;
                if (flags & MNT_RDONLY)
                        args.export.ex_flags = MNT_EXRDONLY;
@@ -259,7 +257,6 @@ mountfs(spec, name, flags, type, options, mntopts)
                        args.export.ex_flags = 0;
                argp = (caddr_t)&args;
                break;
                        args.export.ex_flags = 0;
                argp = (caddr_t)&args;
                break;
-
        case MOUNT_MFS:
        case MOUNT_NFS:
        default:
        case MOUNT_MFS:
        case MOUNT_NFS:
        default:
@@ -267,7 +264,7 @@ mountfs(spec, name, flags, type, options, mntopts)
                argc = 1;
                if (flags) {
                        argv[argc++] = "-F";
                argc = 1;
                if (flags) {
                        argv[argc++] = "-F";
-                       sprintf(flagval, "%d", flags);
+                       (void)snprintf(flagval, sizeof(flagval), "%d", flags);
                        argv[argc++] = flagval;
                }
                if (mntopts)
                        argv[argc++] = flagval;
                }
                if (mntopts)
@@ -277,7 +274,8 @@ mountfs(spec, name, flags, type, options, mntopts)
                argv[argc++] = spec;
                argv[argc++] = name;
                argv[argc++] = NULL;
                argv[argc++] = spec;
                argv[argc++] = name;
                argv[argc++] = NULL;
-               sprintf(execname, "%s/mount_%s", _PATH_EXECDIR, mntname);
+               snprintf(execname, sizeof(execname),
+                   "%s/mount_%s", _PATH_EXECDIR, mntname);
                if (verbose) {
                        (void)printf("exec: %s", execname);
                        for (i = 1; i < argc - 1; i++)
                if (verbose) {
                        (void)printf("exec: %s", execname);
                        for (i = 1; i < argc - 1; i++)
@@ -288,59 +286,54 @@ mountfs(spec, name, flags, type, options, mntopts)
                        break;
                if (pid = vfork()) {
                        if (pid == -1) {
                        break;
                if (pid = vfork()) {
                        if (pid == -1) {
-                               perror("mount: vfork starting file system");
+                               warn("vfork starting file system");
                                return (1);
                        }
                                return (1);
                        }
-                       if (waitpid(pid, (int *)&status, 0) != -1 &&
+                       if (waitpid(pid, &status, 0) != -1 &&
                            WIFEXITED(status) &&
                            WEXITSTATUS(status) != 0)
                                return (WEXITSTATUS(status));
                        spec = mntname;
                        goto out;
                }
                            WIFEXITED(status) &&
                            WEXITSTATUS(status) != 0)
                                return (WEXITSTATUS(status));
                        spec = mntname;
                        goto out;
                }
-               execve(execname, argv, envp);
-               (void) fprintf(stderr, "mount: cannot exec %s for %s: ",
-                       execname, name);
-               perror((char *)NULL);
-               exit (1);
+               execv(execname, argv);
+               err(1, "cannot exec %s for %s", execname, name);
                /* NOTREACHED */
 
        }
        if (!debug && mount(mnttype, name, flags, argp)) {
                /* NOTREACHED */
 
        }
        if (!debug && mount(mnttype, name, flags, argp)) {
-               (void) fprintf(stderr, "%s on %s: ", spec, name);
+               (void)fprintf(stderr, "%s on %s: ", spec, name);
                switch (errno) {
                case EMFILE:
                switch (errno) {
                case EMFILE:
-                       (void) fprintf(stderr, "Mount table full\n");
+                       (void)fprintf(stderr, "Mount table full.\n");
                        break;
                case EINVAL:
                        if (flags & MNT_UPDATE)
                        break;
                case EINVAL:
                        if (flags & MNT_UPDATE)
-                               (void) fprintf(stderr, "Specified device %s\n",
+                               (void)fprintf(stderr, "Specified device %s\n",
                                        "does not match mounted device");
                        else if (mnttype == MOUNT_UFS)
                                        "does not match mounted device");
                        else if (mnttype == MOUNT_UFS)
-                               (void) fprintf(stderr, "Bogus super block\n");
+                               (void)fprintf(stderr, "Bogus super block\n");
                        else
                        else
-                               perror((char *)NULL);
+                               perror(NULL);
                        break;
                default:
                        break;
                default:
-                       perror((char *)NULL);
+                       perror(NULL);
                        break;
                }
                        break;
                }
-               return(1);
+               return (1);
        }
 
        }
 
-out:
-       if (verbose)
+out:   if (verbose)
                prmount(spec, name, flags);
                prmount(spec, name, flags);
-
-       return(0);
+       return (0);
 }
 
 }
 
-static void
+void
 prmount(spec, name, flags)
        char *spec, *name;
 prmount(spec, name, flags)
        char *spec, *name;
-       register short flags;
+       int flags;
 {
 {
-       register int first;
+       int first;
 
        (void)printf("%s on %s", spec, name);
        if (!(flags & MNT_VISFLAGMASK)) {
 
        (void)printf("%s on %s", spec, name);
        if (!(flags & MNT_VISFLAGMASK)) {
@@ -372,46 +365,32 @@ prmount(spec, name, flags)
        (void)printf(")\n");
 }
 
        (void)printf(")\n");
 }
 
+int
 getmnttype(fstype)
        char *fstype;
 {
 
        mntname = fstype;
 getmnttype(fstype)
        char *fstype;
 {
 
        mntname = fstype;
-       if (!strcmp(fstype, "ufs"))
-               return (MOUNT_UFS);
-       return (0);
-}
-
-usage()
-{
-
-       (void) fprintf(stderr,
-               "usage:\n  mount %s %s\n  mount %s\n  mount %s\n",
-               "[ -frwu ] [ -t ufs | external_type ]",
-               "[ -o options ] special node",
-               "[ -afrwu ] [ -t ufs | external_type ]",
-               "[ -frwu ] special | node");
-       exit(1);
+       return (strcmp(fstype, "ufs") == 0 ? MOUNT_UFS : 0);
 }
 
 }
 
+void
 getstdopts(options, flagp)
        char *options;
        int *flagp;
 {
 getstdopts(options, flagp)
        char *options;
        int *flagp;
 {
-       register char *opt;
        int negative;
        int negative;
-       char optbuf[BUFSIZ];
+       char *opt, optbuf[BUFSIZ];
 
        (void)strcpy(optbuf, options);
 
        (void)strcpy(optbuf, options);
-       for (opt = strtok(optbuf, ","); opt; opt = strtok((char *)NULL, ",")) {
+       for (opt = strtok(optbuf, ","); opt; opt = strtok(NULL, ",")) {
                if (opt[0] == '-')
                        continue;
                if (opt[0] == 'n' && opt[1] == 'o') {
                        negative++;
                        opt += 2;
                if (opt[0] == '-')
                        continue;
                if (opt[0] == 'n' && opt[1] == 'o') {
                        negative++;
                        opt += 2;
-               } else {
+               } else
                        negative = 0;
                        negative = 0;
-               }
                if (!negative && !strcasecmp(opt, FSTAB_RO)) {
                        *flagp |= MNT_RDONLY;
                        continue;
                if (!negative && !strcasecmp(opt, FSTAB_RO)) {
                        *flagp |= MNT_RDONLY;
                        continue;
@@ -462,26 +441,29 @@ getstdopts(options, flagp)
                                *flagp &= ~MNT_UNION;
                        continue;
                }
                                *flagp &= ~MNT_UNION;
                        continue;
                }
-               (void) fprintf(stderr, "mount: %s: unknown option\n", opt);
+               (void)fprintf(stderr, "mount: %s: unknown option\n", opt);
        }
 }
 
 /* ARGSUSED */
        }
 }
 
 /* ARGSUSED */
+void
 getufsopts(options, flagp)
        char *options;
        int *flagp;
 {
 getufsopts(options, flagp)
        char *options;
        int *flagp;
 {
+
        return;
 }
 
        return;
 }
 
+int
 getexecopts(options, argv)
 getexecopts(options, argv)
-       char *options;
-       char **argv;
+       char *options, **argv;
 {
 {
-       register int argc = 0;
-       register char *opt;
+       int argc;
+       char *opt;
 
 
-       for (opt = strtok(options, ","); opt; opt = strtok((char *)NULL, ",")) {
+       argc = 0;
+       for (opt = strtok(options, ","); opt; opt = strtok(NULL, ",")) {
                if (opt[0] != '-')
                        continue;
                argv[argc++] = opt;
                if (opt[0] != '-')
                        continue;
                argv[argc++] = opt;
@@ -497,9 +479,8 @@ struct statfs *
 getmntpt(name)
        char *name;
 {
 getmntpt(name)
        char *name;
 {
-       long mntsize;
-       register long i;
        struct statfs *mntbuf;
        struct statfs *mntbuf;
+       long i, mntsize;
 
        mntsize = getmntinfo(&mntbuf, MNT_NOWAIT);
        for (i = 0; i < mntsize; i++) {
 
        mntsize = getmntinfo(&mntbuf, MNT_NOWAIT);
        for (i = 0; i < mntsize; i++) {
@@ -507,36 +488,36 @@ getmntpt(name)
                    !strcmp(mntbuf[i].f_mntonname, name))
                        return (&mntbuf[i]);
        }
                    !strcmp(mntbuf[i].f_mntonname, name))
                        return (&mntbuf[i]);
        }
-       return ((struct statfs *)0);
+       return (NULL);
 }
 
 }
 
-static int skipvfs;
-
+int
 badvfstype(vfstype, vfslist)
 badvfstype(vfstype, vfslist)
-       short vfstype;
+       int vfstype;
        char **vfslist;
 {
 
        char **vfslist;
 {
 
-       if (vfslist == 0)
-               return(0);
-       while (*vfslist) {
+       if (vfslist == NULL)
+               return (0);
+       while (*vfslist != NULL) {
                if (vfstype == getmnttype(*vfslist))
                if (vfstype == getmnttype(*vfslist))
-                       return(skipvfs);
+                       return (skipvfs);
                vfslist++;
        }
        return (!skipvfs);
 }
 
                vfslist++;
        }
        return (!skipvfs);
 }
 
+int
 badvfsname(vfsname, vfslist)
        char *vfsname;
        char **vfslist;
 {
 
 badvfsname(vfsname, vfslist)
        char *vfsname;
        char **vfslist;
 {
 
-       if (vfslist == 0)
-               return(0);
-       while (*vfslist) {
+       if (vfslist == NULL)
+               return (0);
+       while (*vfslist != NULL) {
                if (strcmp(vfsname, *vfslist) == 0)
                if (strcmp(vfsname, *vfslist) == 0)
-                       return(skipvfs);
+                       return (skipvfs);
                vfslist++;
        }
        return (!skipvfs);
                vfslist++;
        }
        return (!skipvfs);
@@ -546,8 +527,8 @@ char **
 makevfslist(fslist)
        char *fslist;
 {
 makevfslist(fslist)
        char *fslist;
 {
-       register char **av, *nextcp;
-       register int i;
+       int i;
+       char **av, *nextcp;
 
        if (fslist == NULL)
                return (NULL);
 
        if (fslist == NULL)
                return (NULL);
@@ -558,16 +539,29 @@ 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((size_t)(i+2) * sizeof(char *));
+       av = malloc((size_t)(i + 2) * sizeof(char *));
        if (av == NULL)
                return (NULL);
        nextcp = fslist;
        i = 0;
        av[i++] = nextcp;
        if (av == NULL)
                return (NULL);
        nextcp = fslist;
        i = 0;
        av[i++] = nextcp;
-       while (nextcp = index(nextcp, ',')) {
+       while ((nextcp = index(nextcp, ',')) != NULL) {
                *nextcp++ = '\0';
                av[i++] = nextcp;
        }
                *nextcp++ = '\0';
                av[i++] = nextcp;
        }
-       av[i++] = 0;
+       av[i++] = NULL;
        return (av);
 }
        return (av);
 }
+
+void
+usage()
+{
+
+       (void)fprintf(stderr,
+               "usage:\n  mount %s %s\n  mount %s\n  mount %s\n",
+               "[ -frwu ] [ -t ufs | external_type ]",
+               "[ -o options ] special node",
+               "[ -afrwu ] [ -t ufs | external_type ]",
+               "[ -frwu ] special | node");
+       exit(1);
+}