[Patch 3/8] NFS Mount Configuration File (Vers 2)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



commit 528e270be6bb3e4a072cbbb7f3a8b378b64b7fba
Author: Steve Dickson <steved@xxxxxxxxxx>
Date:   Mon Mar 9 13:57:10 2009 -0400

    Store values in lower case. This makes it easier to do string
    comparisons when reading lists from the configuration file.
    
    Signed-off-by: Steve Dickson <steved@xxxxxxxxxx>

diff --git a/support/nfs/conffile.c b/support/nfs/conffile.c
index b36200b..f5e0f79 100644
--- a/support/nfs/conffile.c
+++ b/support/nfs/conffile.c
@@ -114,7 +114,16 @@ conf_hash(char *s)
 	}
 	return hash;
 }
+/*
+ * Convert letter from upper case to lower case
+ */
+static inline upper2lower(char *str)
+{
+	char *ptr = str;
 
+	while (*ptr) 
+		*ptr++ = tolower(*ptr);
+}
 /*
  * Insert a tag-value combination from LINE (the equal sign is at POS)
  */
@@ -523,7 +532,7 @@ conf_get_tag_list(char *section)
 	for (; cb; cb = LIST_NEXT(cb, link)) {
 		if (strcasecmp (section, cb->section) == 0) {
 			list->cnt++;
-			node = calloc (1, sizeof *node);
+			node = calloc(1, sizeof *node);
 			if (!node)
 				goto cleanup;
 			node->field = strdup(cb->tag);
@@ -615,7 +624,7 @@ conf_free_list(struct conf_list *list)
 }
 
 int
-conf_begin (void)
+conf_begin(void)
 {
   static int seq = 0;
 
@@ -623,7 +632,7 @@ conf_begin (void)
 }
 
 static struct conf_trans *
-conf_trans_node (int transaction, enum conf_op op)
+conf_trans_node(int transaction, enum conf_op op)
 {
 	struct conf_trans *node;
 
@@ -639,9 +648,9 @@ conf_trans_node (int transaction, enum conf_op op)
 	return node;
 }
 
-/* Queue a set operation.  */
+/* Queue a set operation.  Store value in lower case */
 int
-conf_set (int transaction, char *section, char *tag, 
+conf_set(int transaction, char *section, char *tag, 
 	char *value, int override, int is_default)
 {
 	struct conf_trans *node;
@@ -654,16 +663,22 @@ conf_set (int transaction, char *section, char *tag,
 		xlog_warn("conf_set: strdup(\"%s\") failed", section);
 		goto fail;
 	}
+	upper2lower(node->section);
+
 	node->tag = strdup(tag);
 	if (!node->tag) {
 		xlog_warn("conf_set: strdup(\"%s\") failed", tag);
 		goto fail;
 	}
+	upper2lower(node->tag);
+
 	node->value = strdup(value);
 	if (!node->value) {
 		xlog_warn("conf_set: strdup(\"%s\") failed", value);
 		goto fail;
 	}
+	upper2lower(node->value);
+
 	node->override = override;
 	node->is_default = is_default;
 	return 0;

--
To unsubscribe from this list: send the line "unsubscribe linux-nfs" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Filesystem Development]     [Linux USB Development]     [Linux Media Development]     [Video for Linux]     [Linux NILFS]     [Linux Audio Users]     [Yosemite Info]     [Linux SCSI]

  Powered by Linux