X-Git-Url: https://git.decadent.org.uk/gitweb/?p=nfs-utils.git;a=blobdiff_plain;f=utils%2Fmount%2Fnfsmount.c;h=ff0ff9307a9b3655f8cc360a147d89c6c53d3576;hp=7befbee2933c44724bf945181e3713db9a7c476e;hb=3c1bb23c0379864722e79d19f74c180edcf2c36e;hpb=2f1ade1adf8074efbd661d41758d8844ab5f522e diff --git a/utils/mount/nfsmount.c b/utils/mount/nfsmount.c index 7befbee..ff0ff93 100644 --- a/utils/mount/nfsmount.c +++ b/utils/mount/nfsmount.c @@ -35,6 +35,10 @@ * nfsmount.c,v 1.1.1.1 1993/11/18 08:40:51 jrs Exp */ +#ifdef HAVE_CONFIG_H +#include +#endif + #include #include #include @@ -488,14 +492,14 @@ out_bad: int nfsmount(const char *spec, const char *node, int flags, - char **extra_opts, int fake) + char **extra_opts, int fake, int running_bg) { static char *prev_bg_host; char hostdir[1024]; char *hostname, *dirname, *old_opts, *mounthost = NULL; char new_opts[1024], cbuf[1024]; static struct nfs_mount_data data; - int val, running_bg = 0; + int val; static int doonce = 0; clnt_addr_t mnt_server = { &mounthost, }; @@ -688,15 +692,15 @@ nfsmount(const char *spec, const char *node, int flags, if (errno == ETIMEDOUT) break; default: - mount_errors(*nfs_server.hostname, 0, bg); + rpc_mount_errors(*nfs_server.hostname, 0, bg); goto fail; } t = time(NULL); if (t >= timeout) { - mount_errors(*nfs_server.hostname, 0, bg); + rpc_mount_errors(*nfs_server.hostname, 0, bg); goto fail; } - mount_errors(*nfs_server.hostname, 1, bg); + rpc_mount_errors(*nfs_server.hostname, 1, bg); continue; } if (!running_bg) { @@ -707,14 +711,14 @@ nfsmount(const char *spec, const char *node, int flags, } t = time(NULL); if (t >= timeout) { - mount_errors(*nfs_server.hostname, 0, bg); + rpc_mount_errors(*nfs_server.hostname, 0, bg); goto fail; } if (doonce++ < 1) - mount_errors(*nfs_server.hostname, 1, bg); + rpc_mount_errors(*nfs_server.hostname, 1, bg); } - if (nfs_pmap->pm_vers == 2) { + if (mnt_pmap->pm_vers <= 2) { if (mntres.nfsv2.fhs_status != 0) { nfs_error(_("%s: %s:%s failed, reason given by server: %s"), progname, hostname, dirname, @@ -734,7 +738,7 @@ nfsmount(const char *spec, const char *node, int flags, #if NFS_MOUNT_VERSION >= 4 mountres3_ok *mountres; fhandle3 *fhandle; - int i, *flavor, yum = 0; + int i, n_flavors, *flavor, yum = 0; if (mntres.nfsv3.fhs_status != 0) { nfs_error(_("%s: %s:%s failed, reason given by server: %s"), progname, hostname, dirname, @@ -743,13 +747,16 @@ nfsmount(const char *spec, const char *node, int flags, } #if NFS_MOUNT_VERSION >= 5 mountres = &mntres.nfsv3.mountres3_u.mountinfo; - i = mountres->auth_flavors.auth_flavors_len; - if (i <= 0) + n_flavors = mountres->auth_flavors.auth_flavors_len; + if (n_flavors <= 0) goto noauth_flavors; flavor = mountres->auth_flavors.auth_flavors_val; - while (--i >= 0) { - /* If no flavour requested, use first simple + for (i = 0; i < n_flavors; ++i) { + /* + * Per RFC2623, section 2.7, we should prefer the + * flavour listed first. + * If no flavour requested, use the first simple * flavour that is offered. */ if (! (data.flags & NFS_MOUNT_SECFLAVOUR) && @@ -848,7 +855,7 @@ noauth_flavors: if (!start_statd()) { nfs_error(_("%s: rpc.statd is not running but is " "required for remote locking.\n" - " Either use '-o nolocks' to keep " + " Either use '-o nolock' to keep " "locks local, or start statd."), progname); goto fail; @@ -863,7 +870,7 @@ noauth_flavors: } } - return 0; + return EX_SUCCESS; /* abort */ fail: