Skip to contentSkip to conversation

merge vers= and nfsvers= options in mount.nfs

PATCH In review Justin Mitchell 2 participants 2 messages Oct 2, 2017 – Oct 5, 2017

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 merge vers= and nfsvers= options in mount.nfs

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.

---
 utils/mount/configfile.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)
utils/mount/configfile.c +5 -3
index e4b39ef..64688bf 100644
@@ -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);
Signature · 1 line
1.8.3.1
#1 lore raw
Quoted 6 lines · Justin Mitchell

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.

Committed...

steved.

Quoted 42 lines
---
 utils/mount/configfile.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)
utils/mount/configfile.c +5 -3
index e4b39ef..64688bf 100644
@@ -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);