- if (fake)
- return 0;
- if (mnt_err)
- exit(EX_FAIL);
-
- mnt_err = do_mount_syscall(spec, mount_point,
- nfs_mount_vers == 4 ? "nfs4" : "nfs",
- flags, mount_opts);
-
- if (mnt_err) {
- mount_error(mount_point);
- exit(EX_FAIL);
+ mnt_err = try_mount(spec, mount_point, flags, fs_type, &extra_opts,
+ mount_opts, fake, FOREGROUND);
+ if (mnt_err == EX_BG) {
+ printf(_("%s: backgrounding \"%s\"\n"),
+ progname, spec);
+ printf(_("%s: mount options: \"%s\"\n"),
+ progname, extra_opts);
+
+ fflush(stdout);
+
+ /*
+ * Parent exits immediately with success.
+ */
+ if (daemon(0, 0)) {
+ nfs_error(_("%s: failed to start "
+ "background process: %s\n"),
+ progname, strerror(errno));
+ exit(EX_FAIL);
+ }
+
+ mnt_err = try_mount(spec, mount_point, flags, fs_type,
+ &extra_opts, mount_opts, fake,
+ BACKGROUND);
+ if (verbose && mnt_err)
+ printf(_("%s: giving up \"%s\"\n"),
+ progname, spec);