Fix mtab so it works on libc5
[oweals/busybox.git] / mount.c
diff --git a/mount.c b/mount.c
index cddccadb45b4c6d2f7c8d6b3da5f2f929f0f391c..58d43696416142914c109b1627ce6306dff6de96 100644 (file)
--- a/mount.c
+++ b/mount.c
@@ -231,7 +231,7 @@ parse_mount_options(char *options, int *flags, char *strflags)
        }
 }
 
-int
+static int
 mount_one(char *blockDevice, char *directory, char *filesystemType,
                  unsigned long flags, char *string_flags, int useMtab, int fakeIt,
                  char *mtab_opts, int whineOnErrors)
@@ -239,18 +239,28 @@ mount_one(char *blockDevice, char *directory, char *filesystemType,
        int status = 0;
 
        if (strcmp(filesystemType, "auto") == 0) {
-               int i=0;
+               static const char *strings[] = { "tmpfs", "shm", "proc", "ramfs", "devpts", 0 };
+               const char** nodevfss;
                const int num_of_filesystems = sysfs(3, 0, 0);
                char buf[255];
+               int i=0;
+
                filesystemType=buf;
 
                while(i < num_of_filesystems) {
                        sysfs(2, i++, filesystemType);
-                       status = do_mount(blockDevice, directory, filesystemType,
+                       for (nodevfss = strings; *nodevfss; nodevfss++) {
+                               if (!strcmp(filesystemType, *nodevfss)) {
+                                       break;
+                               }
+                       }
+                       if (!*nodevfss) {
+                               status = do_mount(blockDevice, directory, filesystemType,
                                        flags | MS_MGC_VAL, string_flags,
                                        useMtab, fakeIt, mtab_opts);
-                       if (status == TRUE)
-                               break;
+                               if (status == TRUE)
+                                       break;
+                       }
                }
        } else {
                status = do_mount(blockDevice, directory, filesystemType,
@@ -430,6 +440,7 @@ extern int mount_main(int argc, char **argv)
                        device = strdup(m->mnt_fsname);
                        directory = strdup(m->mnt_dir);
                        filesystemType = strdup(m->mnt_type);
+                       string_flags = strdup(string_flags);
 singlemount:                   
                        rc = EXIT_SUCCESS;
 #ifdef BB_NFSMOUNT