X-Git-Url: https://git.decadent.org.uk/gitweb/?p=nfs-utils.git;a=blobdiff_plain;f=utils%2Fmount%2Fnfs4mount.c;h=a2f318fa47da13b3af4885ee514bd7d6e1fc7703;hp=0a32c3c4f644444e135ebb2405b6130077960fc3;hb=2498a68b1bec01d0ee8a63962b314140e8289036;hpb=4398901d336340f5bef59991d4cea77b2970f2fe diff --git a/utils/mount/nfs4mount.c b/utils/mount/nfs4mount.c index 0a32c3c..a2f318f 100644 --- a/utils/mount/nfs4mount.c +++ b/utils/mount/nfs4mount.c @@ -18,6 +18,10 @@ * - Moved to nfs-utils/utils/mount from util-linux/mount. */ +#ifdef HAVE_CONFIG_H +#include +#endif + #include #include #include @@ -30,6 +34,7 @@ #include #include #include + #ifdef HAVE_RPCSVC_NFS_PROT_H #include #else @@ -41,6 +46,7 @@ #include "nls.h" #include "xcommon.h" +#include "mount.h" #include "mount_constants.h" #include "nfs4_mount.h" #include "nfs_mount.h" @@ -184,10 +190,9 @@ int nfs4mount(const char *spec, const char *node, int flags, int bg, soft, intr; int nocto, noac, unshared; int retry; - int retval; + int retval = EX_FAIL; time_t timeout, t; - retval = EX_FAIL; if (strlen(spec) >= sizeof(hostdir)) { nfs_error(_("%s: excessively long host:dir argument\n"), progname); @@ -234,7 +239,7 @@ int nfs4mount(const char *spec, const char *node, int flags, nocto = 0; noac = 0; unshared = 0; - retry = 10000; /* 10000 minutes ~ 1 week */ + retry = -1; /* * NFSv4 specifies that the default port should be 2049 @@ -328,6 +333,14 @@ int nfs4mount(const char *spec, const char *node, int flags, } } + /* if retry is still -1, then it wasn't set via an option */ + if (retry == -1) { + if (bg) + retry = 10000; /* 10000 mins == ~1 week */ + else + retry = 2; /* 2 min default on fg mounts */ + } + data.flags = (soft ? NFS4_MOUNT_SOFT : 0) | (intr ? NFS4_MOUNT_INTR : 0) | (nocto ? NFS4_MOUNT_NOCTO : 0) @@ -431,6 +444,13 @@ int nfs4mount(const char *spec, const char *node, int flags, rpc_mount_errors(hostname, 0, bg); goto fail; } + + if (bg && !running_bg) { + if (retry > 0) + retval = EX_BG; + goto fail; + } + t = time(NULL); if (t >= timeout) { rpc_mount_errors(hostname, 0, bg);