X-Git-Url: https://git.decadent.org.uk/gitweb/?p=nfs-utils.git;a=blobdiff_plain;f=utils%2Fmount%2Fstropts.c;h=9b4197b7f93d812958da2b4eaffd73cba5600836;hp=f1aa5030062e2cb7bee232d6f14ea880ace688b0;hb=329c63dd7e4e76fc66e8a6058d95c59974ad7db1;hpb=930323817b61877d61fb8ef57229013daa2e6091 diff --git a/utils/mount/stropts.c b/utils/mount/stropts.c index f1aa503..9b4197b 100644 --- a/utils/mount/stropts.c +++ b/utils/mount/stropts.c @@ -16,8 +16,8 @@ * * You should have received a copy of the GNU General Public * License along with this program; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 021110-1307, USA. + * Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 0211-1301 USA * */ @@ -437,8 +437,8 @@ static int nfs_construct_new_options(struct mount_options *options, if (po_append(options, new_option) == PO_FAILED) return 0; - po_remove_all(options, "port"); - if (nfs_pmap->pm_port != NFS_PORT) { + if(po_remove_all(options, "port") == PO_FOUND || + nfs_pmap->pm_port != NFS_PORT) { snprintf(new_option, sizeof(new_option) - 1, "port=%lu", nfs_pmap->pm_port); if (po_append(options, new_option) == PO_FAILED) @@ -538,6 +538,10 @@ nfs_rewrite_pmap_mount_options(struct mount_options *options) errno = ESPIPE; if (rpc_createerr.cf_stat == RPC_PROGNOTREGISTERED) errno = EOPNOTSUPP; + else if (rpc_createerr.cf_stat == RPC_AUTHERROR) + errno = EACCES; + else if (rpc_createerr.cf_stat == RPC_TIMEDOUT) + errno = ETIMEDOUT; else if (rpc_createerr.cf_error.re_errno != 0) errno = rpc_createerr.cf_error.re_errno; return 0; @@ -661,11 +665,13 @@ static int nfs_try_mount_v3v2(struct nfsmount_info *mi) case ECONNREFUSED: case EOPNOTSUPP: case EHOSTUNREACH: + case ETIMEDOUT: continue; default: - break; + goto out; } } +out: return ret; } @@ -674,6 +680,7 @@ static int nfs_do_mount_v4(struct nfsmount_info *mi, { struct mount_options *options = po_dup(mi->options); int result = 0; + char *extra_opts = NULL; if (!options) { errno = ENOMEM; @@ -709,20 +716,26 @@ static int nfs_do_mount_v4(struct nfsmount_info *mi, goto out_fail; } - /* - * Update option string to be recorded in /etc/mtab. - */ - if (po_join(options, mi->extra_opts) == PO_FAILED) { + if (po_join(options, &extra_opts) == PO_FAILED) { errno = ENOMEM; goto out_fail; } if (verbose) printf(_("%s: trying text-based options '%s'\n"), - progname, *mi->extra_opts); + progname, extra_opts); result = nfs_sys_mount(mi, options); + /* + * If success, update option string to be recorded in /etc/mtab. + */ + if (result) { + free(*mi->extra_opts); + *mi->extra_opts = extra_opts; + } else + free(extra_opts); + out_fail: po_destroy(options); return result; @@ -747,11 +760,13 @@ static int nfs_try_mount_v4(struct nfsmount_info *mi) switch (errno) { case ECONNREFUSED: case EHOSTUNREACH: + case ETIMEDOUT: continue; default: - break; + goto out; } } +out: return ret; } @@ -905,7 +920,8 @@ static int nfsmount_parent(struct nfsmount_info *mi) if (nfs_try_mount(mi)) return EX_SUCCESS; - if (nfs_is_permanent_error(errno)) { + /* retry background mounts when the server is not up */ + if (nfs_is_permanent_error(errno) && errno != EOPNOTSUPP) { mount_error(mi->spec, mi->node, errno); return EX_FAIL; } @@ -940,7 +956,8 @@ static int nfsmount_child(struct nfsmount_info *mi) if (nfs_try_mount(mi)) return EX_SUCCESS; - if (nfs_is_permanent_error(errno)) + /* retry background mounts when the server is not up */ + if (nfs_is_permanent_error(errno) && errno != EOPNOTSUPP) break; if (time(NULL) > timeout)