X-Git-Url: https://git.decadent.org.uk/gitweb/?p=nfs-utils.git;a=blobdiff_plain;f=utils%2Fmount%2Fnfsmount.c;h=1298fe44485789bae59cc10cf7430c2599b4f5a5;hp=a9dd91764fbb7276521245885133c928640966f7;hb=706bfd7c94d48659a1411fdef2a3a61d4719f1aa;hpb=5f7cc524008a7dc548a71f4c7b0d39759371a37a diff --git a/utils/mount/nfsmount.c b/utils/mount/nfsmount.c index a9dd917..1298fe4 100644 --- a/utils/mount/nfsmount.c +++ b/utils/mount/nfsmount.c @@ -21,7 +21,7 @@ * Wed Oct 1 23:55:28 1997: Dick Streefland * Implemented the "bg", "fg" and "retry" mount options for NFS. * - * 1999-02-22 Arkadiusz Mi¶kiewicz + * 1999-02-22 Arkadiusz Miskiewicz * - added Native Language Support * * Modified by Olaf Kirch and Trond Myklebust for new NFS code, @@ -67,6 +67,14 @@ #include "nls.h" #include "error.h" #include "network.h" +#include "version.h" + +#ifdef HAVE_RPCSVC_NFS_PROT_H +#include +#else +#include +#define nfsstat nfs_stat +#endif #ifndef NFS_PORT #define NFS_PORT 2049 @@ -95,8 +103,6 @@ extern char *progname; extern int verbose; extern int sloppy; -extern int linux_version_code(void); - static inline enum clnt_stat nfs3_mount(CLIENT *clnt, mnt3arg_t *mnt3arg, mnt3res_t *mnt3res) { @@ -164,7 +170,7 @@ parse_options(char *old_opts, struct nfs_mount_data *data, struct pmap *mnt_pmap = &mnt_server->pmap; struct pmap *nfs_pmap = &nfs_server->pmap; int len; - char *opt, *opteq, *p, *opt_b; + char *opt, *opteq, *p, *opt_b, *tmp_opts; char *mounthost = NULL; char cbuf[128]; int open_quote = 0; @@ -173,7 +179,8 @@ parse_options(char *old_opts, struct nfs_mount_data *data, *bg = 0; len = strlen(new_opts); - for (p=old_opts, opt_b=NULL; p && *p; p++) { + tmp_opts = xstrdup(old_opts); + for (p=tmp_opts, opt_b=NULL; p && *p; p++) { if (!opt_b) opt_b = p; /* begin of the option item */ if (*p == '"') @@ -451,10 +458,12 @@ parse_options(char *old_opts, struct nfs_mount_data *data, goto out_bad; *mnt_server->hostname = mounthost; } + free(tmp_opts); return 1; bad_parameter: nfs_error(_("%s: Bad nfs mount parameter: %s\n"), progname, opt); out_bad: + free(tmp_opts); return 0; } @@ -494,7 +503,6 @@ int nfsmount(const char *spec, const char *node, int flags, 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]; @@ -502,8 +510,12 @@ nfsmount(const char *spec, const char *node, int flags, int val; static int doonce = 0; - clnt_addr_t mnt_server = { &mounthost, }; - clnt_addr_t nfs_server = { &hostname, }; + clnt_addr_t mnt_server = { + .hostname = &mounthost + }; + clnt_addr_t nfs_server = { + .hostname = &hostname + }; struct sockaddr_in *nfs_saddr = &nfs_server.saddr; struct pmap *mnt_pmap = &mnt_server.pmap, *nfs_pmap = &nfs_server.pmap; @@ -628,18 +640,6 @@ nfsmount(const char *spec, const char *node, int flags, if (flags & MS_REMOUNT) goto out_ok; - /* - * If the previous mount operation on the same host was - * backgrounded, and the "bg" for this mount is also set, - * give up immediately, to avoid the initial timeout. - */ - if (bg && !running_bg && - prev_bg_host && strcmp(hostname, prev_bg_host) == 0) { - if (retry > 0) - retval = EX_BG; - return retval; - } - /* create mount deamon client */ /* @@ -708,7 +708,6 @@ nfsmount(const char *spec, const char *node, int flags, continue; } if (!running_bg) { - prev_bg_host = xstrdup(hostname); if (retry > 0) retval = EX_BG; goto fail; @@ -822,7 +821,7 @@ noauth_flavors: * to avoid problems with multihomed hosts. * --Swen */ - if (linux_version_code() <= 0x01030a && fsock != -1 + if (linux_version_code() <= MAKE_VERSION(1, 3, 10) && fsock != -1 && connect(fsock, (struct sockaddr *) nfs_saddr, sizeof (*nfs_saddr)) < 0) { perror(_("nfs connect"));