[PATCH 17/25] autofs-5.0.7 - fix dumpmaps multi output

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

 



If the maps contain the old style "multi" type the dumped map information
isn't right.
---
 CHANGELOG    |    1 +
 lib/master.c |   61 +++++++++++++++++++++++++++++++++++++++++++++++-----------
 2 files changed, 50 insertions(+), 12 deletions(-)

diff --git a/CHANGELOG b/CHANGELOG
index 5764cb0..5e58aca 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -68,6 +68,7 @@
 - use LIBS for link libraries.
 - unbundle NOTSTRIP from DEBUG so they dont depend on each other.
 - fix compilation of lookup_ldap.c without sasl.
+- fix dumpmaps multi output.
 
 25/07/2012 autofs-5.0.7
 =======================
diff --git a/lib/master.c b/lib/master.c
index eca3523..df6c141 100644
--- a/lib/master.c
+++ b/lib/master.c
@@ -1281,6 +1281,54 @@ static void list_source_instances(struct map_source *source, struct map_source *
 	return;
 }
 
+static void print_map_info(struct map_source *source)
+{
+	int argc = source->argc;
+	int i, multi, map_num;
+
+	multi = (source->type && !strcmp(source->type, "multi"));
+	map_num = 1;
+	for (i = 0; i < argc; i++) {
+		if (source->argv[i] && *source->argv[i] != '-') {
+			if (!multi)
+				printf("  map: %s\n", source->argv[i]);
+			else
+				printf("  map[%i]: %s\n", map_num, source->argv[i]);
+			i++;
+		}
+
+		if (i >= argc)
+			return;
+
+		if (!strcmp(source->argv[i], "--"))
+			continue;
+
+		if (source->argv[i]) {
+			int need_newline = 0;
+			int j;
+
+			if (!multi)
+				printf("  arguments:");
+			else
+				printf("  arguments[%i]:", map_num);
+
+			for (j = i; j < source->argc; j++) {
+				if (!strcmp(source->argv[j], "--"))
+					break;
+				printf(" %s", source->argv[j]);
+				i++;
+				need_newline = 1;
+			}
+			if (need_newline)
+				printf("\n");
+		}
+		if (multi)
+			map_num++;
+	}
+
+	return;
+}
+
 int master_show_mounts(struct master *master)
 {
 	struct list_head *p, *head;
@@ -1311,7 +1359,6 @@ int master_show_mounts(struct master *master)
 		struct autofs_point *ap;
 		time_t now = time(NULL);
 		unsigned int count = 0;
-		int i;
 
 		this = list_entry(p, struct master_mapent, list);
 		p = p->next;
@@ -1357,20 +1404,10 @@ int master_show_mounts(struct master *master)
 			}
 
 			if (source->argc >= 1) {
-				i = 0;
-				if (source->argv[0] && *source->argv[0] != '-') {
-					printf("  map: %s\n", source->argv[0]);
-					i = 1;
-				}
+				print_map_info(source);
 				if (count && ap->type == LKP_INDIRECT)
 					printf("  duplicate indirect map entry"
 					       " will be ignored at run time\n");
-				if (source->argc > 1) {
-					printf("  arguments: ");
-					for (; i < source->argc; i++)
-						printf("%s ", source->argv[i]);
-					printf("\n");
-				}
 			}
 
 			printf("\n");

--
To unsubscribe from this list: send the line "unsubscribe autofs" 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 Ext4]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux