// Not real flags, but we want to be able to check for this.
enum {
- MOUNT_USERS = (1<<28)*ENABLE_DESKTOP,
- MOUNT_NOAUTO = (1<<29),
- MOUNT_SWAP = (1<<30),
+ MOUNT_USERS = (1 << 28) * ENABLE_DESKTOP,
+ MOUNT_NOAUTO = (1 << 29),
+ MOUNT_SWAP = (1 << 30),
};
errno = 0;
rc = mount(source, target, filesystemtype, mountflags, data);
if (verbose >= 2)
- bb_perror_msg("would do mount('%s','%s','%s',0x%08lx,'%s'):%d"
- + (sizeof("would do ")-1),
+ bb_perror_msg("mount('%s','%s','%s',0x%08lx,'%s'):%d",
source, target, filesystemtype,
mountflags, (char*)data, rc);
return rc;
if (ENABLE_FEATURE_MOUNT_HELPERS && rc) {
char *args[6];
int errno_save = errno;
- args[0] = mp->mnt_type;
+ args[0] = xasprintf("mount.%s", mp->mnt_type);
rc = 1;
if (filteropts) {
args[rc++] = (char *)"-o";
args[rc++] = mp->mnt_dir;
args[rc] = NULL;
rc = wait4pid(spawn(args));
+ free(args[0]);
if (!rc)
break;
errno = errno_save;
// Treat fstype "auto" as unspecified.
- if (mp->mnt_type && strcmp(mp->mnt_type,"auto") == 0)
- mp->mnt_type = 0;
+ if (mp->mnt_type && strcmp(mp->mnt_type, "auto") == 0)
+ mp->mnt_type = NULL;
// Might this be a virtual filesystem?
) {
char *s, *p, *args[35];
int n = 0;
+// FIXME: does it allow execution of arbitrary commands?!
+// What args[0] can end up with?
for (s = p = mp->mnt_fsname; *s && n < 35-3; ++s) {
if (s[0] == '#' && s[1] != '#') {
*s = '\0';
// Might this be an CIFS filesystem?
if (ENABLE_FEATURE_MOUNT_CIFS
- && (!mp->mnt_type || strcmp(mp->mnt_type,"cifs") == 0)
- && (mp->mnt_fsname[0]=='/' || mp->mnt_fsname[0]=='\\')
- && mp->mnt_fsname[0]==mp->mnt_fsname[1]
+ && (!mp->mnt_type || strcmp(mp->mnt_type, "cifs") == 0)
+ && (mp->mnt_fsname[0] == '/' || mp->mnt_fsname[0] == '\\')
+ && mp->mnt_fsname[0] == mp->mnt_fsname[1]
) {
len_and_sockaddr *lsa;
char *ip, *dotted;
{
enum { OPT_ALL = 0x10 };
- char *cmdopts = xstrdup(""), *fstype=0, *storage_path=0;
+ char *cmdopts = xstrdup("");
+ char *fstype = NULL;
+ char *storage_path = NULL;
char *opt_o;
const char *fstabname;
FILE *fstab;
append_mount_options(&cmdopts, argv[i]+2);
} else argv[j++] = argv[i];
}
- argv[j] = 0;
+ argv[j] = NULL;
argc = j;
// Parse remaining options
} else {
// Do we need to match a filesystem type?
- if (fstype && match_fstype(mtcur, fstype)) continue;
+ if (fstype && match_fstype(mtcur, fstype))
+ continue;
// Skip noauto and swap anyway.
- if (parse_mount_options(mtcur->mnt_opts, 0)
- & (MOUNT_NOAUTO | MOUNT_SWAP)) continue;
+ if (parse_mount_options(mtcur->mnt_opts, 0) & (MOUNT_NOAUTO | MOUNT_SWAP))
+ continue;
// No, mount -a won't mount anything,
// even user mounts, for mere humans.
bb_error_msg_and_die(must_be_root);
// Mount this thing.
- if (ENABLE_FEATURE_MOUNT_LABEL) {
+ if (ENABLE_FEATURE_MOUNT_LABEL)
resolve_mount_spec(&mtpair->mnt_fsname);
- }
// NFS mounts want this to be xrealloc-able
mtcur->mnt_opts = xstrdup(mtcur->mnt_opts);