]> git.decadent.org.uk Git - nfs-utils.git/blobdiff - utils/mount/nfsmount.c
nfs-utils: NFSv4: fix backgrounding
[nfs-utils.git] / utils / mount / nfsmount.c
index 6a045184d55648f7ec156d8b994f1fa97470338b..6b3356c05efe57d6a7ee0efeac665c530c2446ad 100644 (file)
 #include "nls.h"
 #include "error.h"
 #include "network.h"
+#include "version.h"
+
+#ifdef HAVE_RPCSVC_NFS_PROT_H
+#include <rpcsvc/nfs_prot.h>
+#else
+#include <linux/nfs.h>
+#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;
 }
 
@@ -808,7 +817,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"));