must get mount type when reading from fstab
authorKirk McKusick <mckusick@ucbvax.Berkeley.EDU>
Wed, 13 Sep 1989 13:07:58 +0000 (05:07 -0800)
committerKirk McKusick <mckusick@ucbvax.Berkeley.EDU>
Wed, 13 Sep 1989 13:07:58 +0000 (05:07 -0800)
SCCS-vsn: sbin/mount/mount.c 5.12

usr/src/sbin/mount/mount.c

index d0c4b38..e90c89c 100644 (file)
@@ -11,13 +11,14 @@ char copyright[] =
 #endif not lint
 
 #ifndef lint
 #endif not lint
 
 #ifndef lint
-static char sccsid[] = "@(#)mount.c    5.11 (Berkeley) %G%";
+static char sccsid[] = "@(#)mount.c    5.12 (Berkeley) %G%";
 #endif not lint
 
 #include "pathnames.h"
 #include <sys/param.h>
 #include <sys/file.h>
 #include <sys/time.h>
 #endif not lint
 
 #include "pathnames.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 <fstab.h>
 #include <errno.h>
 #include <stdio.h>
@@ -110,18 +111,8 @@ main(argc, argv, arge)
                        options = optarg;
                        break;
                case 't':
                        options = optarg;
                        break;
                case 't':
-                       if (!strcmp(optarg, "ufs")) {
-                               mnttype = MOUNT_UFS;
+                       if (mnttype = getmnttype(optarg))
                                break;
                                break;
-                       }
-                       if (!strcmp(optarg, "nfs")) {
-                               mnttype = MOUNT_NFS;
-                               break;
-                       }
-                       if (!strcmp(optarg, "mfs")) {
-                               mnttype = MOUNT_MFS;
-                               break;
-                       }
                        /* fall through */
                case '?':
                default:
                        /* fall through */
                case '?':
                default:
@@ -141,6 +132,12 @@ main(argc, argv, arge)
                        /* `/' is special, it's always mounted */
                        if (!strcmp(fs->fs_file, "/"))
                                fake = 1;
                        /* `/' is special, it's always mounted */
                        if (!strcmp(fs->fs_file, "/"))
                                fake = 1;
+                       if ((mnttype = getmnttype(fs->fs_vfstype)) == 0) {
+                               fprintf(stderr,
+                                   "%s %s type of file system is unknown.\n",
+                                   "mount:", fs->fs_vfstype);
+                               continue;
+                       }
                        rval |= mountfs(fs->fs_spec, fs->fs_file,
                            type ? type : fs->fs_type, options, fs->fs_mntops);
                }
                        rval |= mountfs(fs->fs_spec, fs->fs_file,
                            type ? type : fs->fs_type, options, fs->fs_mntops);
                }
@@ -180,9 +177,6 @@ main(argc, argv, arge)
                exit(0);
        }
 
                exit(0);
        }
 
-       if (all)
-               usage();
-
        if (argc == 1) {
                if (!(fs = getfsfile(*argv)) && !(fs = getfsspec(*argv))) {
                        fprintf(stderr,
        if (argc == 1) {
                if (!(fs = getfsfile(*argv)) && !(fs = getfsspec(*argv))) {
                        fprintf(stderr,
@@ -195,6 +189,12 @@ main(argc, argv, arge)
                            "mount: %s has unknown file system type.\n", *argv);
                        exit(1);
                }
                            "mount: %s has unknown file system type.\n", *argv);
                        exit(1);
                }
+               if ((mnttype = getmnttype(fs->fs_vfstype)) == 0) {
+                       fprintf(stderr,
+                           "mount: %s type of file system is unknown.\n",
+                           fs->fs_vfstype);
+                       exit(1);
+               }
                exit(mountfs(fs->fs_spec, fs->fs_file,
                    type ? type : fs->fs_type, options, fs->fs_mntops));
        }
                exit(mountfs(fs->fs_spec, fs->fs_file,
                    type ? type : fs->fs_type, options, fs->fs_mntops));
        }
@@ -329,7 +329,19 @@ prmount(spec, name, type)
        printf("\n");
 }
 
        printf("\n");
 }
 
-static
+getmnttype(fstype)
+       char *fstype;
+{
+
+       if (!strcmp(fstype, "ufs"))
+               return (MOUNT_UFS);
+       if (!strcmp(fstype, "nfs"))
+               return (MOUNT_NFS);
+       if (!strcmp(fstype, "mfs"))
+               return (MOUNT_MFS);
+       return (0);
+}
+
 usage()
 {
        fprintf(stderr, "usage: mount [-afrw]\nor mount [-frw] special | node\nor mount [-frw] special node\n");
 usage()
 {
        fprintf(stderr, "usage: mount [-afrw]\nor mount [-frw] special | node\nor mount [-frw] special node\n");