Linux NFS development
 help / color / mirror / Atom feed
From: Justin Mitchell <jumitche@redhat.com>
To: Linux NFS Mailing list <linux-nfs@vger.kernel.org>
Cc: Steve Dickson <steved@redhat.com>
Subject: [PATCH nfs-utils] merge vers= and nfsvers= options in mount.nfs
Date: Mon, 02 Oct 2017 09:02:24 +0100	[thread overview]
Message-ID: <1506931344.3753.3.camel@redhat.com> (raw)

When using mount.nfs if an nfsvers= option is set in a config file,
and a vers= option is given on the commandline, then they are not
always correctly combined and this can result in both being present
in the resulting mount call.

Signed-off-by: Justin Mitchell <jumitche@redhat.com>
---
 utils/mount/configfile.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/utils/mount/configfile.c b/utils/mount/configfile.c
index e4b39ef..64688bf 100644
--- a/utils/mount/configfile.c
+++ b/utils/mount/configfile.c
@@ -66,6 +66,7 @@ struct mnt_alias {
 	{"background", "bg", MNT_NOARG},
 	{"foreground", "fg", MNT_NOARG},
 	{"sloppy", "sloppy", MNT_NOARG},
+	{"nfsvers", "vers", MNT_UNSET},
 };
 int mnt_alias_sz = (sizeof(mnt_alias_tab)/sizeof(mnt_alias_tab[0]));
 
@@ -292,20 +293,21 @@ conf_parse_mntopts(char *section, char *arg, char *opts)
 
 	list = conf_get_tag_list(section, arg);
 	TAILQ_FOREACH(node, &list->fields, link) {
+		/* check first if this is an alias for another option */
+		field = mountopts_alias(node->field, &argtype);
 		/*
 		 * Do not overwrite options if already exists 
 		 */
-		snprintf(buf, BUFSIZ, "%s=", node->field);
+		snprintf(buf, BUFSIZ, "%s=", field);
 		if (opts && strcasestr(opts, buf) != NULL)
 			continue;
 
-		if (lookup_entry(node->field) != NULL)
+		if (lookup_entry(field) != NULL)
 			continue;
 		buf[0] = '\0';
 		value = conf_get_section(section, arg, node->field);
 		if (value == NULL)
 			continue;
-		field = mountopts_alias(node->field, &argtype);
 		if (strcasecmp(value, "false") == 0) {
 			if (argtype != MNT_NOARG)
 				snprintf(buf, BUFSIZ, "no%s", field);
-- 
1.8.3.1




             reply	other threads:[~2017-10-02  8:02 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-10-02  8:02 Justin Mitchell [this message]
2017-10-05 14:55 ` [PATCH nfs-utils] merge vers= and nfsvers= options in mount.nfs Steve Dickson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1506931344.3753.3.camel@redhat.com \
    --to=jumitche@redhat.com \
    --cc=linux-nfs@vger.kernel.org \
    --cc=steved@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox