aboutsummaryrefslogtreecommitdiff
path: root/sbin/mount_nfs
diff options
context:
space:
mode:
authorIan Dowse <iedowse@FreeBSD.org>2001-07-19 21:11:48 +0000
committerIan Dowse <iedowse@FreeBSD.org>2001-07-19 21:11:48 +0000
commite16873dad691bbdc6ab5e197b9d7a8ecfb703f7e (patch)
treef5072bb2dd361c29f89116db705c73eede284cb2 /sbin/mount_nfs
parent19f2be11b00aedee7658772eebf4d324ec9fa949 (diff)
downloadsrc-e16873dad691bbdc6ab5e197b9d7a8ecfb703f7e.tar.gz
src-e16873dad691bbdc6ab5e197b9d7a8ecfb703f7e.zip
Since revision 1.40/1.41, the default behaviour for mount_nfs is
to give up after one attempt unless a background mount is requested. Background mounts would retry 10000 times (at least 7 days) before giving up. For some situations such as diskless terminals, an NFS filesystem may be critical to the boot process, so neither the "try once" nor background mounts are appropiate. To cater for this situation, unbreak the -R (retry count) parameter so that it also works in the non-background case. Interpret a zero retry count as "retry forever". The defaults are now "try once" for non-background mounts and "retry forever" for background mounts; both can be overridden via -R. Add a description of this behaviour to the manpage.
Notes
Notes: svn path=/head/; revision=80006
Diffstat (limited to 'sbin/mount_nfs')
-rw-r--r--sbin/mount_nfs/mount_nfs.89
-rw-r--r--sbin/mount_nfs/mount_nfs.c23
2 files changed, 20 insertions, 12 deletions
diff --git a/sbin/mount_nfs/mount_nfs.8 b/sbin/mount_nfs/mount_nfs.8
index 97600b5ef827..f12b8c72d137 100644
--- a/sbin/mount_nfs/mount_nfs.8
+++ b/sbin/mount_nfs/mount_nfs.8
@@ -125,7 +125,14 @@ more secure.
but untrustworthy users and the network cables are in secure areas this does
help, but for normal desktop clients this does not apply.)
.It Fl R
-Set the retry count for doing the mount to the specified value.
+Set the mount retry count to the specified value.
+A retry count of zero means to keep retrying forever.
+By default,
+.Nm
+retries forever on background mounts (see the
+.Fl b
+option), and otherwise tries just once.
+There is a 60 second delay between each attempt.
.It Fl T
Use TCP transport instead of UDP.
This is recommended for servers that are not on the same LAN cable as
diff --git a/sbin/mount_nfs/mount_nfs.c b/sbin/mount_nfs/mount_nfs.c
index b6667c58ac6d..997cc9231581 100644
--- a/sbin/mount_nfs/mount_nfs.c
+++ b/sbin/mount_nfs/mount_nfs.c
@@ -178,10 +178,9 @@ struct nfhret {
long fhsize;
u_char nfh[NFSX_V3FHMAX];
};
-#define DEF_RETRY 10000
#define BGRND 1
#define ISBGRND 2
-int retrycnt = DEF_RETRY;
+int retrycnt = -1;
int opflags = 0;
int nfsproto = IPPROTO_UDP;
int mnttcp_ok = 1;
@@ -289,7 +288,6 @@ main(argc, argv)
((char *)ktick.kt.dat) - ((char *)&ktick) != 2 * NFSX_UNSIGNED)
fprintf(stderr, "Yikes! NFSKERB structs not packed!!\n");
#endif /* NFSKERB */
- retrycnt = DEF_RETRY;
mntflags = 0;
altflags = 0;
@@ -430,7 +428,7 @@ main(argc, argv)
break;
case 'R':
num = strtol(optarg, &p, 10);
- if (*p || num <= 0)
+ if (*p || num < 0)
errx(1, "illegal -R value -- %s", optarg);
retrycnt = num;
break;
@@ -487,6 +485,8 @@ main(argc, argv)
spec = *argv++;
name = *argv;
+ if (retrycnt == -1)
+ retrycnt = (opflags & BGRND) ? 0 : 1;
if (!getnfsargs(spec, nfsargsp))
exit(1);
@@ -694,7 +694,7 @@ getnfsargs(spec, nfsargsp)
#endif /* NFSKERB */
ret = TRYRET_LOCALERR;
- while (retrycnt > 0) {
+ for (;;) {
/*
* Try each entry returned by getaddrinfo(). Note the
* occurence of remote errors by setting `remoteerr'.
@@ -712,14 +712,15 @@ getnfsargs(spec, nfsargsp)
if (ret == TRYRET_SUCCESS)
break;
- /*
- * Exit on failures if not BGRND mode, or if all errors
- * were local.
- */
- if ((opflags & BGRND) == 0 || !remoteerr)
+ /* Exit if all errors were local. */
+ if (!remoteerr)
exit(1);
- if (--retrycnt <= 0)
+ /*
+ * If retrycnt == 0, we are to keep retrying forever.
+ * Otherwise decrement it, and exit if it hits zero.
+ */
+ if (retrycnt != 0 && --retrycnt == 0)
exit(1);
if ((opflags & (BGRND | ISBGRND)) == BGRND) {