Skip to contentSkip to conversation

add '-t' option to dump internal hwtable

PATCH In review Hannes Reinecke 1 participant 1 message May 21, 2007 Device mapper

lore
Share & tools
lore
#0 lore raw

PATCH 8/21 add '-t' option to dump internal hwtable

This patch adds an option '-t' to dump the internal hardware table. Quite handy if you want to know the default settings.
In doing so it also fixes the keyword allocation; currently the keywords are only initialised if a configuration file is used.

---
 libmultipath/config.c |    5 +++-
 libmultipath/parser.c |   15 +++++++++---
 libmultipath/parser.h |    1 +
 libmultipath/print.c  |    2 +-
 multipath/main.c      |   57 +++++++++++++++++++++++++++++++++++++++++++++++-
 5 files changed, 72 insertions(+), 8 deletions(-)
libmultipath/config.c +4 -1
index a39af8a..1dfc18c 100644
@@ -366,12 +366,15 @@ load_config (char * file)
 	/*
 	 * read the config file
 	 */
+	set_current_keywords(&conf->keywords);
+	alloc_keywords();
 	if (filepresent(file)) {
-		set_current_keywords(&conf->keywords);
 		if (init_data(file, init_keywords)) {
 			condlog(0, "error parsing config file");
 			goto out;
 		}
+	} else {
+	    init_keywords();
 	}
 	
 	/*
libmultipath/parser.c +11 -4
index f9c555e..5302970 100644
@@ -455,16 +455,23 @@ process_stream(vector keywords)
 	return r;
 }
 
+int alloc_keywords(void)
+{
+	if (!keywords)
+		keywords = vector_alloc();
+
+	if (!keywords)
+		return 1;
+
+	return 0;
+}
+
 /* Data initialization */
 int
 init_data(char *conf_file, void (*init_keywords) (void))
 {
 	int r;
 
-	if (!keywords)
-		keywords = vector_alloc();
-	if (!keywords)
-		return 1;
 	stream = fopen(conf_file, "r");
 	if (!stream) {
 		syslog(LOG_WARNING, "Configuration file open problem");
libmultipath/parser.h +1 -0
index 95d4e6f..8496684 100644
@@ -74,6 +74,7 @@ extern vector read_value_block(void);
 extern int alloc_value_block(vector strvec, void (*alloc_func) (vector));
 extern void *set_value(vector strvec);
 extern int process_stream(vector keywords);
+extern int alloc_keywords(void);
 extern int init_data(char *conf_file, void (*init_keywords) (void));
 extern struct keyword * find_keyword(vector v, char * name);
 void set_current_keywords (vector *k);
libmultipath/print.c +1 -1
index e50f37d..dc8af48 100644
@@ -734,7 +734,7 @@ snprint_hwentry (char * buff, int len, s
 	if (fwd > len)
 		return len;
 	iterate_sub_keywords(rootkw, kw, i) {
-		fwd += snprint_keyword(buff + fwd, len - fwd, "\t\t%k %v\n",
+		fwd += snprint_keyword(buff + fwd, len - fwd, "\t\t%k \"%v\"\n",
 				kw, hwe);
 		if (fwd > len)
 			return len;
multipath/main.c +55 -2

87 lines not on this page · raw message

Signature · 1 line
1.4.3.4