]> git.decadent.org.uk Git - nfs-utils.git/commitdiff
mount options can be lost when using bg option
authorHarshula Jayasuriya <harshula@redhat.com>
Mon, 16 Nov 2009 18:39:35 +0000 (13:39 -0500)
committerSteve Dickson <steved@redhat.com>
Mon, 16 Nov 2009 18:39:35 +0000 (13:39 -0500)
When mounting an NFS export *without* the "bg" option, try_mount() is
called only once. Before calling it, the variables mount_opts and
extra_opts are set up. Then try_mount() calls nfsmount(), the latter
assumes that the aforementioned variables can be modified. Most
significantly, it allows the variable extra_opts to be modified.

When the "bg" mount option is used *and* the first try_mount() attempt
fails, it daemonizes the process and calls try_mount() again,
unfortunately, we've lost the required mount options in the variable
extra_opts.

See https://bugzilla.redhat.com/show_bug.cgi?id=529370 for details.

Signed-off-by: Harshula Jayasuriya <harshula@redhat.com>
Signed-off-by: Steve Dickson <steved@redhat.com>
utils/mount/mount.c
utils/mount/nfsmount.c

index 355df796c2448c05fb25cab6f620491de8ec2cea..6b9e1642c43fa1087dada7d38db47ee4126f5906 100644 (file)
@@ -593,6 +593,9 @@ int main(int argc, char *argv[])
        if (mnt_err == EX_BG) {
                printf(_("%s: backgrounding \"%s\"\n"),
                        progname, spec);
+               printf(_("%s: mount options: \"%s\"\n"),
+                       progname, extra_opts);
+
                fflush(stdout);
 
                /*
index 6355681d4b520eeb3bdeacb26ed81cf797ea33cc..6b3356c05efe57d6a7ee0efeac665c530c2446ad 100644 (file)
@@ -170,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;
@@ -179,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 == '"')
@@ -457,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;
 }