summaryrefslogtreecommitdiffstats
path: root/utils/mount/mount.c
diff options
context:
space:
mode:
authorChuck Lever <chuck.lever@oracle.com>2007-08-03 13:24:15 -0400
committerNeil Brown <neilb@suse.de>2007-08-04 08:27:40 +1000
commit1f1fa09103d71be48287d5393f82ee9a92927b2e (patch)
tree28556e0f4485dbeeb1f6ab88b5155100cb16d607 /utils/mount/mount.c
parent0ab024c2ffddfdb8262c1355c97573327c2b8539 (diff)
downloadnfs-utils-1f1fa09103d71be48287d5393f82ee9a92927b2e.tar.gz
nfs-utils-1f1fa09103d71be48287d5393f82ee9a92927b2e.tar.xz
nfs-utils-1f1fa09103d71be48287d5393f82ee9a92927b2e.zip
mount.nfs: Fix background mounts
The new mount.nfs helper does not support background mounts. Add support for background mounts. Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: Neil Brown <neilb@suse.de>
Diffstat (limited to 'utils/mount/mount.c')
-rw-r--r--utils/mount/mount.c24
1 files changed, 23 insertions, 1 deletions
diff --git a/utils/mount/mount.c b/utils/mount/mount.c
index c0c3971..a232519 100644
--- a/utils/mount/mount.c
+++ b/utils/mount/mount.c
@@ -49,6 +49,9 @@ int nomtab;
int verbose;
int sloppy;
+#define FOREGROUND (0)
+#define BACKGROUND (1)
+
static struct option longopts[] = {
{ "fake", 0, 0, 'f' },
{ "help", 0, 0, 'h' },
@@ -518,7 +521,26 @@ int main(int argc, char *argv[])
}
mnt_err = try_mount(spec, mount_point, flags, fs_type, &extra_opts,
- mount_opts, fake, nomtab, 0);
+ mount_opts, fake, nomtab, FOREGROUND);
+ if (mnt_err == EX_BG) {
+ printf(_("mount: backgrounding \"%s\"\n"), spec);
+ fflush(stdout);
+
+ /*
+ * Parent exits immediately with success. Make
+ * sure not to free "mount_point"
+ */
+ if (fork() > 0)
+ exit(0);
+
+ mnt_err = try_mount(spec, mount_point, flags, fs_type,
+ &extra_opts, mount_opts, fake,
+ nomtab, BACKGROUND);
+ if (verbose && mnt_err)
+ printf(_("%s: giving up \"%s\"\n"),
+ progname, spec);
+ exit(0);
+ }
out:
free(mount_point);