text-based mount.nfs: add a function to do foreground retries
Subsystems (2)
PATCH 18/24 text-based mount.nfs: add a function to do foreground retries
Make the differences between the foreground and background mount logic explicit by creating separate functions to handle each -- think of them as separate scripts for doing a foreground or a background mount.
NFS foreground mounts are supposed to retry for a little while before giving up. Add a function that handles this.
---
utils/mount/stropts.c | 50 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 50 insertions(+), 0 deletions(-)
utils/mount/stropts.c +50 -0
@@ -426,6 +426,56 @@ parse_err: }/* +* Handle "foreground" NFS mounts. +* +* Retry the mount request for as long as the 'retry=' option says. +* +* Returns a valid mount command return code: zero if successful, +* EX_FAIL if a failure occurred. +*/ +static int nfsmount_fg (const char *spec,const char *node, +int flags,struct mount_options *options, +int fake,char **extra_opts) +{ +unsigned int secs =1 ; +time_t timeout =time (NULL ); +char *retry; + + retry =po_get (options,"retry" ); +if (!retry) + timeout +=60 *2 ;/* default: 2 minutes */ +else + timeout +=60 *atoi (retry); + +for (;;) { +if (try_nfsmount (spec, node, flags, options, + fake, extra_opts)) +return 0 ; + +if (is_permanent_error (errno)) +break ; + +if (time (NULL ) > timeout) { + errno =ETIMEDOUT ; +break ; + } + +if (verbose) +printf (_ ("%s: will retry until %s\n" ), + progname,ctime (&timeout)); + +if (sleep (secs)) +break ; + secs <<=1 ; +if (secs >5 ) + secs =5 ; + }; + +mount_error (spec, node, errno); +return EX_FAIL ; +} + +/* * nfsmount_s - Mount an NFSv2 or v3 file system using C string options * * @spec: C string hostname:path specifying remoteshare to mount
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
NFS maillist - [email protected]
https://lists.sourceforge.net/lists/listinfo/nfs