--- util-linux-2.13-pre6/mount/mount.c 2005-08-14 11:16:33.000000000 -0400 +++ util-linux-2.13-pre6-new/mount/mount.c 2006-03-18 00:25:50.000000000 -0500 @@ -100,9 +100,10 @@ struct opt_map { #define MS_GROUP 0x08000000 #define MS_COMMENT 0x00020000 #define MS_LOOP 0x00010000 +#define MS_BG 0x04000000 /* Options that we keep the mount system call from seeing. */ -#define MS_NOSYS (MS_NOAUTO|MS_USERS|MS_USER|MS_COMMENT|MS_LOOP) +#define MS_NOSYS (MS_NOAUTO|MS_USERS|MS_USER|MS_COMMENT|MS_LOOP|MS_BG) /* Options that we keep from appearing in the options field in the mtab. */ #define MS_NOMTAB (MS_REMOUNT|MS_NOAUTO|MS_USERS|MS_USER) @@ -143,6 +144,7 @@ static const struct opt_map opt_map[] = { "comment", 0, 0, MS_COMMENT}, /* fstab comment only (kudzu,_netdev)*/ /* add new options here */ + { "bg", 1, 0, MS_BG }, /* fork this mount into the background */ #ifdef MS_NOSUB { "sub", 0, 1, MS_NOSUB }, /* allow submounts */ { "nosub", 0, 0, MS_NOSUB }, /* don't allow submounts */ @@ -791,6 +793,7 @@ try_mount_one (const char *spec0, const const char *loopdev = 0, *loopfile = 0; struct stat statbuf; int nfs_mount_version = 0; /* any version */ + pid_t pid = -1; /* copies for freeing on exit */ const char *opts1, *spec1, *node1, *types1, *extra_opts1; @@ -850,28 +853,41 @@ retry_nfs: block_signals (SIG_BLOCK); - if (!fake) - mnt5_res = guess_fstype_and_mount (spec, node, &types, flags & ~MS_NOSYS, - mount_opts); + if (!fake) { + /* Don't bother checking if fork failed because if it does, we will just + * act as if MS_BG was not specified in the first place */ + if (flags & MS_BG) + pid = fork(); + if (pid == -1 || pid == 0) + mnt5_res = guess_fstype_and_mount (spec, node, &types, flags & ~MS_NOSYS, + mount_opts); + } if (fake || mnt5_res == 0) { /* Mount succeeded, report this (if verbose) and write mtab entry. */ if (loop) opt_loopdev = loopdev; - update_mtab_entry(loop ? loopfile : spec, + if (pid == -1 || pid == 0) { + update_mtab_entry(loop ? loopfile : spec, node, types ? types : "unknown", fix_opts_string (flags & ~MS_NOMTAB, extra_opts, user), flags, freq, pass); + if (pid == 0) + exit(mnt5_res); + } block_signals (SIG_UNBLOCK); res = 0; goto out; } + if (pid == 0) + exit(mnt5_res); + mnt_err = errno; if (loop)