static void append_mount_options(char **oldopts, char *newopts)
{
if(*oldopts && **oldopts) {
- char *temp=xasprintf("%s,%s",*oldopts,newopts);
+ char *temp = xasprintf("%s,%s",*oldopts,newopts);
free(*oldopts);
- *oldopts=temp;
+ *oldopts = temp;
} else {
if (ENABLE_FEATURE_CLEAN_UP) free(*oldopts);
*oldopts = xstrdup(newopts);
}
/* Use the mount_options list to parse options into flags.
- * Return list of unrecognized options in *strflags if strflags!=NULL */
+ * Also return list of unrecognized options if unrecognized!=NULL */
static int parse_mount_options(char *options, char **unrecognized)
{
int flags = MS_SILENT;
#endif
#if ENABLE_FEATURE_MTAB_SUPPORT
-static int useMtab;
+static int useMtab = 1;
static int fakeIt;
#else
#define useMtab 0
#endif
// Perform actual mount of specific filesystem at specific location.
-
-static int mount_it_now(struct mntent *mp, int vfsflags, char *filteropts)
+int mount_it_now(struct mntent *mp, int vfsflags, char *filteropts)
{
int rc;
int i;
if(!mountTable)
- bb_error_msg("No %s\n",bb_path_mtab_file);
+ bb_error_msg("no %s",bb_path_mtab_file);
// Add vfs string flags
// Write and close.
if(!mp->mnt_type || !*mp->mnt_type) mp->mnt_type="--bind";
- addmntent(mountTable, mp);
+// addmntent(mountTable, mp);
+if(0) bb_error_msg("buggy: addmntent(fsname='%s' dir='%s' type='%s' opts='%s')",
+mp->mnt_fsname,
+mp->mnt_dir,
+mp->mnt_type,
+mp->mnt_opts
+);
endmntent(mountTable);
if (ENABLE_FEATURE_CLEAN_UP)
if(strcmp(mp->mnt_type,"--bind")) mp->mnt_type = 0;
return rc;
}
-// Mount one directory. Handles CIFS, NFS, loopback, autobind, and filesystem type
-// detection. Returns 0 for success, nonzero for failure.
+// Mount one directory. Handles CIFS, NFS, loopback, autobind, and filesystem
+// type detection. Returns 0 for success, nonzero for failure.
static int singlemount(struct mntent *mp, int ignore_busy)
{
// compose new unc '\\server-ip\share'
- s = xasprintf("\\\\%s\\%s",ip+3,strchr(mp->mnt_fsname+2,'\\'));
+ s = xasprintf("\\\\%s%s",ip+3,strchr(mp->mnt_fsname+2,'\\'));
if (ENABLE_FEATURE_CLEAN_UP) free(mp->mnt_fsname);
mp->mnt_fsname = s;
(!mp->mnt_type || !strcmp(mp->mnt_type,"nfs")) &&
strchr(mp->mnt_fsname, ':') != NULL)
{
- if (nfsmount(mp->mnt_fsname, mp->mnt_dir, &vfsflags, &filteropts, 1)) {
- bb_perror_msg("nfsmount failed");
- } else {
- // Strangely enough, nfsmount() doesn't actually mount() anything.
- mp->mnt_type = "nfs";
- rc = mount_it_now(mp, vfsflags, filteropts);
- }
+ rc = nfsmount(mp, vfsflags, filteropts);
goto report_error;
}
default:
bb_error_msg( errno == EPERM || errno == EACCES
? bb_msg_perm_denied_are_you_root
- : "Couldn't setup loop device");
+ : "cannot setup loop device");
return errno;
}
// Autodetect bind mounts
- } else if (S_ISDIR(st.st_mode) && !mp->mnt_type) vfsflags |= MS_BIND;
+ } else if (S_ISDIR(st.st_mode) && !mp->mnt_type)
+ vfsflags |= MS_BIND;
}
/* If we know the fstype (or don't need to), jump straight
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);
+ /* perror here sometimes says "mounting ... on ... failed: Success" */
+ bb_error_msg("mounting %s on %s failed", mp->mnt_fsname, mp->mnt_dir);
return rc;
}
if (!all) {
FILE *mountTable = setmntent(bb_path_mtab_file, "r");
- if(!mountTable) bb_error_msg_and_die("No %s",bb_path_mtab_file);
+ if(!mountTable) bb_error_msg_and_die("no %s",bb_path_mtab_file);
while (getmntent_r(mountTable,mtpair,bb_common_bufsiz1,
sizeof(bb_common_bufsiz1)))
else fstabname="/etc/fstab";
if (!(fstab=setmntent(fstabname,"r")))
- bb_perror_msg_and_die("Cannot read %s",fstabname);
+ bb_perror_msg_and_die("cannot read %s",fstabname);
// Loop through entries until we find what we're looking for.
// If we didn't find anything, complain.
if (!mtnext->mnt_fsname)
- bb_error_msg_and_die("Can't find %s in %s",
+ bb_error_msg_and_die("can't find %s in %s",
argv[optind], fstabname);
// Mount the last thing we found.