aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--util-linux/mount.c37
1 files changed, 16 insertions, 21 deletions
diff --git a/util-linux/mount.c b/util-linux/mount.c
index fecf81606..c64c3f438 100644
--- a/util-linux/mount.c
+++ b/util-linux/mount.c
@@ -256,9 +256,9 @@ static int mount_it_now(struct mntent *mp, int vfsflags, char *filteropts)
// Mount one directory. Handles NFS, loopback, autobind, and filesystem type
// detection. Returns 0 for success, nonzero for failure.
-static int singlemount(struct mntent *mp)
+static int singlemount(struct mntent *mp, int ignore_busy)
{
- int rc = 1, vfsflags;
+ int rc = -1, vfsflags;
char *loopFile = 0, *filteropts = 0;
llist_t *fl = 0;
struct stat st;
@@ -277,14 +277,14 @@ static int singlemount(struct mntent *mp)
{
if (nfsmount(mp->mnt_fsname, mp->mnt_dir, &vfsflags, &filteropts, 1)) {
bb_perror_msg("nfsmount failed");
- return 1;
+ goto report_error;
} else {
// Strangely enough, nfsmount() doesn't actually mount() anything.
mp->mnt_type = "nfs";
rc = mount_it_now(mp, vfsflags, filteropts);
if (ENABLE_FEATURE_CLEAN_UP) free(filteropts);
- return rc;
+ goto report_error;
}
}
@@ -354,10 +354,14 @@ static int singlemount(struct mntent *mp)
free(mp->mnt_fsname);
}
}
+report_error:
+ if (rc && errno == EBUSY && ignore_busy) rc = 0;
+ if (rc < 0)
+ bb_perror_msg("Mounting %s on %s failed", mp->mnt_fsname, mp->mnt_dir);
+
return rc;
}
-
// Parse options, if necessary parse fstab/mtab, and call singlemount for
// each directory to be mounted.
@@ -365,7 +369,7 @@ int mount_main(int argc, char **argv)
{
char *cmdopts = bb_xstrdup(""), *fstabname, *fstype=0, *storage_path=0;
FILE *fstab;
- int i, opt, all = FALSE, rc = 1;
+ int i, opt, all = FALSE, rc = 0;
struct mntent mtpair[2], *mtcur = mtpair;
/* parse long options, like --bind and --move. Note that -o option
@@ -447,7 +451,7 @@ int mount_main(int argc, char **argv)
mtpair->mnt_dir = argv[optind+1];
mtpair->mnt_type = fstype;
mtpair->mnt_opts = cmdopts;
- rc = singlemount(mtpair);
+ rc = singlemount(mtpair, 0);
goto clean_up;
}
@@ -491,10 +495,10 @@ int mount_main(int argc, char **argv)
mtcur = mtnext;
mtcur->mnt_opts=bb_xstrdup(mtcur->mnt_opts);
append_mount_options(&(mtcur->mnt_opts),cmdopts);
- rc = singlemount(mtcur);
+ rc = singlemount(mtcur, 0);
free(mtcur->mnt_opts);
}
- break;
+ goto clean_up;
}
/* If we're trying to mount something specific and this isn't it,
@@ -529,14 +533,9 @@ int mount_main(int argc, char **argv)
// Mount this thing.
- rc = singlemount(mtcur);
- if(rc) {
- // Don't whine about already mounted fs when mounting all.
- // Note: we should probably change return value to indicate
- // failure, without causing a duplicate error message.
- if (errno != EBUSY) bb_perror_msg("Mounting %s on %s failed",
- mtcur->mnt_fsname, mtcur->mnt_dir);
- rc = 0;
+ if (singlemount(mtcur, 1)) {
+ /* Count number of failed mounts */
+ rc++;
}
}
}
@@ -549,9 +548,5 @@ clean_up:
free(cmdopts);
}
- if(rc)
- bb_perror_msg("Mounting %s on %s failed",
- mtcur->mnt_fsname, mtcur->mnt_dir);
-
return rc;
}