1 text-based mount command: Fix retry= option
3 Steinar Gunderson reports:
5 "It seems retry= is now additive with the text-based mount interface. In
6 particular, "mount -o retry=0" still gives a two-minute timeout."
8 Make retry option parsing more robust, while we're at it.
10 Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
13 utils/mount/stropts.c | 55 ++++++++++++++++++++++++++++++++++++++-----------
14 1 files changed, 43 insertions(+), 12 deletions(-)
16 diff --git a/utils/mount/stropts.c b/utils/mount/stropts.c
17 index cadb1f4..4df9ad9 100644
18 --- a/utils/mount/stropts.c
19 +++ b/utils/mount/stropts.c
21 #define NFS_MAXPATHNAME (1024)
24 +#ifndef NFS_DEF_FG_TIMEOUT_MINUTES
25 +#define NFS_DEF_FG_TIMEOUT_MINUTES (2ul)
28 +#ifndef NFS_DEF_BG_TIMEOUT_MINUTES
29 +#define NFS_DEF_BG_TIMEOUT_MINUTES (10000ul)
32 extern int nfs_mount_data_version;
33 extern char *progname;
35 @@ -141,6 +149,35 @@ static int fill_ipv4_sockaddr(const char *hostname, struct sockaddr_in *addr)
39 + * Set up a timeout value based on the value of the "retry=" option.
41 + * Returns 1 if the option was parsed successfully, otherwise zero.
42 + * Returns the parsed timeout, or the default, in *timeout.
44 +static int parse_retry_option(time_t *timeout, struct mount_options *options,
45 + unsigned long timeout_minutes)
47 + char *retry_option, *endptr;
49 + retry_option = po_get(options, "retry");
54 + tmp = strtol(retry_option, &endptr, 10);
55 + if (errno || endptr == retry_option || tmp < 0) {
56 + nfs_error(_("%s: incorrect retry timeout specified"),
60 + timeout_minutes = tmp;
63 + *timeout = time(NULL) + (time_t)(timeout_minutes * 60);
68 * Append the 'addr=' option to the options string to pass a resolved
69 * server address to the kernel. After a successful mount, this address
70 * is also added to /etc/mtab for use when unmounting.
71 @@ -535,13 +572,10 @@ static int nfsmount_fg(const char *spec, const char *node,
74 unsigned int secs = 1;
75 - time_t timeout = time(NULL);
79 - timeout += 60 * 2; /* default: 2 minutes */
80 - retry = po_get(options, "retry");
82 - timeout += 60 * atoi(retry);
83 + if (!parse_retry_option(&timeout, options, NFS_DEF_FG_TIMEOUT_MINUTES))
87 printf(_("%s: timeout set for %s"),
88 @@ -612,13 +646,10 @@ static int nfsmount_child(const char *spec, const char *node,
89 int fake, char **extra_opts)
91 unsigned int secs = 1;
92 - time_t timeout = time(NULL);
96 - timeout += 60 * 10000; /* default: 10,000 minutes */
97 - retry = po_get(options, "retry");
99 - timeout += 60 * atoi(retry);
100 + if (!parse_retry_option(&timeout, options, NFS_DEF_BG_TIMEOUT_MINUTES))