-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, int mount_all)
-{
- int status = 0;
-
-#if defined CONFIG_FEATURE_USE_DEVPS_PATCH
- if (strcmp(filesystemType, "auto") == 0) {
- static const char *noauto_array[] = { "tmpfs", "shm", "proc", "ramfs", "devpts", "devfs", "usbdevfs", 0 };
- const char **noauto_fstype;
- 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);
- for (noauto_fstype = noauto_array; *noauto_fstype; noauto_fstype++) {
- if (!strcmp(filesystemType, *noauto_fstype)) {
- break;
- }
- }
- if (!*noauto_fstype) {
- status = do_mount(blockDevice, directory, filesystemType,
- flags | MS_MGC_VAL, string_flags,
- useMtab, fakeIt, mtab_opts, mount_all);
- if (status == TRUE)
- break;
- }
- }
- }
-#else
- if (strcmp(filesystemType, "auto") == 0) {
- char buf[255];
- FILE *f = xfopen("/proc/filesystems", "r");
-
- while (fgets(buf, sizeof(buf), f) != NULL) {
- filesystemType = buf;
- if (*filesystemType == '\t') { // Not a nodev filesystem
-
- // Add NULL termination to each line
- while (*filesystemType && *filesystemType != '\n')
- filesystemType++;
- *filesystemType = '\0';
-
- filesystemType = buf;
- filesystemType++; // hop past tab
-
- status = do_mount(blockDevice, directory, filesystemType,
- flags | MS_MGC_VAL, string_flags,
- useMtab, fakeIt, mtab_opts, mount_all);
- if (status == TRUE)
+ // Look at the file. (Not found isn't a failure for remount, or for
+ // a synthetic filesystem like proc or sysfs.)
+
+ if (lstat(mp->mnt_fsname, &st));
+ else if (!(vfsflags & (MS_REMOUNT | MS_BIND | MS_MOVE))) {
+ // Do we need to allocate a loopback device for it?
+
+ if (ENABLE_FEATURE_MOUNT_LOOP && S_ISREG(st.st_mode)) {
+ loopFile = bb_simplify_path(mp->mnt_fsname);
+ mp->mnt_fsname = 0;
+ switch(set_loop(&(mp->mnt_fsname), loopFile, 0)) {
+ case 0:
+ case 1: