X-Git-Url: https://git.decadent.org.uk/gitweb/?p=nfs-utils.git;a=blobdiff_plain;f=utils%2Fmount%2Fmount.c;h=a6e16851c322a26a3ddcb30feaa1823280da6206;hp=c0c397168b4b91b08f94822f6183d4ca493ace38;hb=3a1a8015fbc5e64d590bd447a8e1a3c16b26b82f;hpb=0ab024c2ffddfdb8262c1355c97573327c2b8539 diff --git a/utils/mount/mount.c b/utils/mount/mount.c index c0c3971..a6e1685 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' }, @@ -267,7 +270,7 @@ fail_unlock: void mount_usage(void) { - printf(_("usage: %s remotetarget dir [-rvVwfnh] [-o nfsoptions]\n"), + printf(_("usage: %s remotetarget dir [-rvVwfnsh] [-o nfsoptions]\n"), progname); printf(_("options:\n")); printf(_("\t-r\t\tMount file system readonly\n")); @@ -276,7 +279,7 @@ void mount_usage(void) printf(_("\t-w\t\tMount file system read-write\n")); printf(_("\t-f\t\tFake mount, do not actually mount\n")); printf(_("\t-n\t\tDo not update /etc/mtab\n")); - printf(_("\t-s\t\tTolerate sloppy mount options rather than failing.\n")); + printf(_("\t-s\t\tTolerate sloppy mount options rather than fail\n")); printf(_("\t-h\t\tPrint this help\n")); printf(_("\tnfsoptions\tRefer to mount.nfs(8) or nfs(5)\n\n")); } @@ -428,7 +431,7 @@ int main(int argc, char *argv[]) break; case 'V': printf("%s: ("PACKAGE_STRING")\n", progname); - return 0; + exit(0); case 'w': flags &= ~MS_RDONLY; break; @@ -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);