aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--util-linux/mount.c22
1 files changed, 15 insertions, 7 deletions
diff --git a/util-linux/mount.c b/util-linux/mount.c
index 831dab9e2..5bc60de59 100644
--- a/util-linux/mount.c
+++ b/util-linux/mount.c
@@ -713,10 +713,12 @@ static int mount_it_now(struct mntent *mp, unsigned long vfsflags, char *filtero
713 errno = 0; 713 errno = 0;
714 rc = verbose_mount(mp->mnt_fsname, mp->mnt_dir, mp->mnt_type, 714 rc = verbose_mount(mp->mnt_fsname, mp->mnt_dir, mp->mnt_type,
715 vfsflags, filteropts); 715 vfsflags, filteropts);
716 if (rc == 0)
717 goto mtab; // success
716 718
717 // If mount failed, try 719 // mount failed, try helper program
718 // helper program mount.<mnt_type> 720 // mount.<mnt_type>
719 if (HELPERS_ALLOWED && rc && mp->mnt_type) { 721 if (HELPERS_ALLOWED && mp->mnt_type) {
720 char *args[8]; 722 char *args[8];
721 int errno_save = errno; 723 int errno_save = errno;
722 args[0] = xasprintf("mount.%s", mp->mnt_type); 724 args[0] = xasprintf("mount.%s", mp->mnt_type);
@@ -734,13 +736,19 @@ static int mount_it_now(struct mntent *mp, unsigned long vfsflags, char *filtero
734 args[rc] = NULL; 736 args[rc] = NULL;
735 rc = spawn_and_wait(args); 737 rc = spawn_and_wait(args);
736 free(args[0]); 738 free(args[0]);
737 if (!rc) 739 if (rc == 0)
738 break; 740 goto mtab; // success
739 errno = errno_save; 741 errno = errno_save;
740 } 742 }
741 743
742 if (!rc || (vfsflags & MS_RDONLY) || (errno != EACCES && errno != EROFS)) 744 // Should we retry read-only mount?
743 break; 745 if (vfsflags & MS_RDONLY)
746 break; // no, already was tried
747 if (option_mask32 & OPT_w)
748 break; // no, "mount -w" never falls back to RO
749 if (errno != EACCES && errno != EROFS)
750 break; // no, error isn't hinting that RO may work
751
744 if (!(vfsflags & MS_SILENT)) 752 if (!(vfsflags & MS_SILENT))
745 bb_error_msg("%s is write-protected, mounting read-only", 753 bb_error_msg("%s is write-protected, mounting read-only",
746 mp->mnt_fsname); 754 mp->mnt_fsname);