[PATCH] mount.c: bail out early when no media exists
sgw at linux.intel.com
sgw at linux.intel.com
Wed Oct 28 14:08:11 UTC 2015
From: "Maxin B. John" <maxin.john at intel.com>
The current behaviour of busybox is to try all fstype when automounting
even when no media exists. The util-linux mount command bails when
no media exists, so change the behaviour of busybox to do the same.
without this fix:
$ time ./busybox mount /dev/cdrom /mnt
mount: mounting /dev/cdrom on /mnt failed: No medium found
real 0m0.573s
user 0m0.000s
sys 0m0.007s
with this fix:
$ time ./busybox mount /dev/cdrom /mnt
mount: mounting /dev/cdrom on /mnt failed: No medium found
real 0m0.042s
user 0m0.000s
sys 0m0.002s
Signed-off-by: Saul Wold <sgw at linux.intel.com>
Signed-off-by: Maxin B. John <maxin.john at intel.com>
---
util-linux/mount.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/util-linux/mount.c b/util-linux/mount.c
index cb40c80..2953758 100644
--- a/util-linux/mount.c
+++ b/util-linux/mount.c
@@ -710,7 +710,13 @@ static int mount_it_now(struct mntent *mp, unsigned long vfsflags, char *filtero
break;
errno = errno_save;
}
-
+ /*
+ * Break if there is no media, no point retrying for all
+ * fs types since there is no media available
+ */
+ if (rc == -1 && errno == ENOMEDIUM) {
+ bb_perror_msg_and_die("mounting %s on %s failed", mp->mnt_fsname, mp->mnt_dir);
+ }
if (!rc || (vfsflags & MS_RDONLY) || (errno != EACCES && errno != EROFS))
break;
if (!(vfsflags & MS_SILENT))
--
2.4.0
More information about the busybox
mailing list