diff options
-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) { |