aboutsummaryrefslogtreecommitdiff
path: root/util-linux
diff options
context:
space:
mode:
authorRon Yorston <rmy@pobox.com>2021-08-30 08:37:51 +0100
committerRon Yorston <rmy@pobox.com>2021-08-30 08:37:51 +0100
commitbdb10f66af52bbd4f9d9340f2cf8ca73adbaee91 (patch)
tree306810231da90fb758cacb38ee9f8a7c4adf0d7c /util-linux
parent6a42f73dcac55a6b5dde810ad60cee7c120a2db7 (diff)
parenta51d953b95a7cc6b40a6b3a5bfd95f3154acf5e2 (diff)
downloadbusybox-w32-bdb10f66af52bbd4f9d9340f2cf8ca73adbaee91.tar.gz
busybox-w32-bdb10f66af52bbd4f9d9340f2cf8ca73adbaee91.tar.bz2
busybox-w32-bdb10f66af52bbd4f9d9340f2cf8ca73adbaee91.zip
Merge branch 'busybox' into merge
Diffstat (limited to 'util-linux')
-rw-r--r--util-linux/mount.c30
1 files changed, 19 insertions, 11 deletions
diff --git a/util-linux/mount.c b/util-linux/mount.c
index 831dab9e2..44afdbcff 100644
--- a/util-linux/mount.c
+++ b/util-linux/mount.c
@@ -562,9 +562,9 @@ static void append_mount_options(char **oldopts, const char *newopts)
562 // Do not insert options which are already there 562 // Do not insert options which are already there
563 while (newopts[0]) { 563 while (newopts[0]) {
564 char *p; 564 char *p;
565 int len = strlen(newopts); 565 int len;
566 p = strchr(newopts, ','); 566
567 if (p) len = p - newopts; 567 len = strchrnul(newopts, ',') - newopts;
568 p = *oldopts; 568 p = *oldopts;
569 while (1) { 569 while (1) {
570 if (!strncmp(p, newopts, len) 570 if (!strncmp(p, newopts, len)
@@ -579,7 +579,7 @@ static void append_mount_options(char **oldopts, const char *newopts)
579 *oldopts = p; 579 *oldopts = p;
580 skip: 580 skip:
581 newopts += len; 581 newopts += len;
582 while (newopts[0] == ',') newopts++; 582 while (*newopts == ',') newopts++;
583 } 583 }
584 } else { 584 } else {
585 if (ENABLE_FEATURE_CLEAN_UP) free(*oldopts); 585 if (ENABLE_FEATURE_CLEAN_UP) free(*oldopts);
@@ -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);