summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenys Vlasenko2021-08-23 02:30:13 +0200
committerDenys Vlasenko2021-08-23 02:30:13 +0200
commitdbdf9e0ab1bfe65b75ba20cdf26c8fded2174c60 (patch)
tree3b19c354d66a5e4dab0c21feb1a659279e3052cc
parent922b58b3e4a26377b5b65c56eec0ac93d80a6fc7 (diff)
downloadbusybox-dbdf9e0ab1bfe65b75ba20cdf26c8fded2174c60.zip
busybox-dbdf9e0ab1bfe65b75ba20cdf26c8fded2174c60.tar.gz
mount: with -w, do not fall back to read-only mounts
function old new delta mount_it_now 364 358 -6 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-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 831dab9..5bc60de 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
errno = 0;
rc = verbose_mount(mp->mnt_fsname, mp->mnt_dir, mp->mnt_type,
vfsflags, filteropts);
+ if (rc == 0)
+ goto mtab; // success
- // If mount failed, try
- // helper program mount.<mnt_type>
- if (HELPERS_ALLOWED && rc && mp->mnt_type) {
+ // mount failed, try helper program
+ // mount.<mnt_type>
+ if (HELPERS_ALLOWED && mp->mnt_type) {
char *args[8];
int errno_save = errno;
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
args[rc] = NULL;
rc = spawn_and_wait(args);
free(args[0]);
- if (!rc)
- break;
+ if (rc == 0)
+ goto mtab; // success
errno = errno_save;
}
- if (!rc || (vfsflags & MS_RDONLY) || (errno != EACCES && errno != EROFS))
- break;
+ // Should we retry read-only mount?
+ if (vfsflags & MS_RDONLY)
+ break; // no, already was tried
+ if (option_mask32 & OPT_w)
+ break; // no, "mount -w" never falls back to RO
+ if (errno != EACCES && errno != EROFS)
+ break; // no, error isn't hinting that RO may work
+
if (!(vfsflags & MS_SILENT))
bb_error_msg("%s is write-protected, mounting read-only",
mp->mnt_fsname);