diff options
author | iedowse <iedowse@FreeBSD.org> | 2001-07-19 21:11:48 +0000 |
---|---|---|
committer | iedowse <iedowse@FreeBSD.org> | 2001-07-19 21:11:48 +0000 |
commit | 1992345c83a44050ef976bd482846cff4f5d31c3 (patch) | |
tree | f5072bb2dd361c29f89116db705c73eede284cb2 /sbin | |
parent | ac76e3b7fe950c13a3975d86d2c5036cb259dc96 (diff) | |
download | FreeBSD-src-1992345c83a44050ef976bd482846cff4f5d31c3.zip FreeBSD-src-1992345c83a44050ef976bd482846cff4f5d31c3.tar.gz |
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.
Diffstat (limited to 'sbin')
-rw-r--r-- | sbin/mount_nfs/mount_nfs.8 | 9 | ||||
-rw-r--r-- | sbin/mount_nfs/mount_nfs.c | 23 |
2 files changed, 20 insertions, 12 deletions
diff --git a/sbin/mount_nfs/mount_nfs.8 b/sbin/mount_nfs/mount_nfs.8 index 97600b5..f12b8c7 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 b6667c5..997cc92 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) { |