summaryrefslogtreecommitdiffstats
path: root/utils/mount/configfile.c
diff options
context:
space:
mode:
authorSteve Dickson <steved@redhat.com>2009-10-17 09:16:18 -0400
committerSteve Dickson <steved@redhat.com>2009-10-22 15:34:20 -0400
commit2f61f62ac777cc03e30513f6fd3699f9e2f04e27 (patch)
treede0a18d8076179c77b6effd70bf49274879df89b /utils/mount/configfile.c
parentf87ae8235ae6042c0e514ba03e4eee7782d5bc6e (diff)
downloadnfs-utils-2f61f62ac777cc03e30513f6fd3699f9e2f04e27.tar.gz
nfs-utils-2f61f62ac777cc03e30513f6fd3699f9e2f04e27.tar.xz
nfs-utils-2f61f62ac777cc03e30513f6fd3699f9e2f04e27.zip
Introducing the parsing of both 'defaultvers' and 'defaultproto'
config variables which will be used to set the the default version and network protocol. A global variable will be set for each option with the corresponding value. The value will be used as the initial value in the server negation. Signed-off-by: Steve Dickson <steved@redhat.com>
Diffstat (limited to 'utils/mount/configfile.c')
-rw-r--r--utils/mount/configfile.c57
1 files changed, 56 insertions, 1 deletions
diff --git a/utils/mount/configfile.c b/utils/mount/configfile.c
index d3285f8..28b722c 100644
--- a/utils/mount/configfile.c
+++ b/utils/mount/configfile.c
@@ -20,13 +20,19 @@
#include <config.h>
#endif
#include <sys/types.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
+#include <errno.h>
#include "xlog.h"
+#include "mount.h"
+#include "parse_opt.h"
+#include "network.h"
#include "conffile.h"
#define KBYTES(x) ((x) * (1024))
@@ -197,6 +203,51 @@ int inline check_vers(char *mopt, char *field)
}
return 0;
}
+
+unsigned long config_default_vers;
+unsigned long config_default_proto;
+/*
+ * Check to see if a default value is being set.
+ * If so, set the appropriate global value which will
+ * be used as the initial value in the server negation.
+ */
+int inline default_value(char *mopt)
+{
+ struct mount_options *options = NULL;
+ int dftlen = strlen("default");
+ char *field;
+
+ if (strncasecmp(mopt, "default", dftlen) != 0)
+ return 0;
+
+ field = mopt + dftlen;
+ if (strncasecmp(field, "proto", strlen("proto")) == 0) {
+ if ((options = po_split(field)) != NULL) {
+ if (!nfs_nfs_protocol(options, &config_default_proto)) {
+ xlog_warn("Unable to set default protocol : %s",
+ strerror(errno));
+ }
+ } else {
+ xlog_warn("Unable to alloc memory for default protocol");
+ }
+ } else if (strncasecmp(field, "vers", strlen("vers")) == 0) {
+ if ((options = po_split(field)) != NULL) {
+ if (!nfs_nfs_version(options, &config_default_vers)) {
+ xlog_warn("Unable to set default version: %s",
+ strerror(errno));
+
+ }
+ } else {
+ xlog_warn("Unable to alloc memory for default version");
+ }
+ } else
+ xlog_warn("Invalid default setting: '%s'", mopt);
+
+ if (options)
+ po_destroy(options);
+
+ return 1;
+}
/*
* Parse the given section of the configuration
* file to if there are any mount options set.
@@ -320,15 +371,19 @@ char *conf_get_mntopts(char *spec, char *mount_point,
free_all();
return mount_opts;
}
+
if (mount_opts) {
strcpy(config_opts, mount_opts);
strcat(config_opts, ",");
}
SLIST_FOREACH(entry, &head, entries) {
+ if (default_value(entry->opt))
+ continue;
strcat(config_opts, entry->opt);
strcat(config_opts, ",");
}
- *(strrchr(config_opts, ',')) = '\0';
+ if ((ptr = strrchr(config_opts, ',')) != NULL)
+ *ptr = '\0';
free_all();
if (mount_opts)