Blame SOURCES/autofs-5.1.2-add-function-conf_amd_get_mount_paths.patch

306fa1
autofs-5.1.2 - add function conf_amd_get_mount_paths()
306fa1
306fa1
From: Ian Kent <raven@themaw.net>
306fa1
306fa1
Add configuration function to get an array of amd mount section
306fa1
paths.
306fa1
306fa1
Signed-off-by: Ian Kent <raven@themaw.net>
306fa1
---
306fa1
 CHANGELOG          |    1 
306fa1
 include/defaults.h |    1 
306fa1
 lib/defaults.c     |   80 +++++++++++++++++++++++++++++++++++++++++++++++++++++
306fa1
 3 files changed, 82 insertions(+)
306fa1
306fa1
--- autofs-5.0.7.orig/CHANGELOG
306fa1
+++ autofs-5.0.7/CHANGELOG
306fa1
@@ -226,6 +226,7 @@
306fa1
 - add ref counting to struct map_source.
306fa1
 - add support for amd browsable option.
306fa1
 - add function conf_amd_get_map_name().
306fa1
+- add function conf_amd_get_mount_paths().
306fa1
 
306fa1
 25/07/2012 autofs-5.0.7
306fa1
 =======================
306fa1
--- autofs-5.0.7.orig/include/defaults.h
306fa1
+++ autofs-5.0.7/include/defaults.h
306fa1
@@ -171,6 +171,7 @@ unsigned int defaults_use_hostname_for_m
306fa1
 unsigned int defaults_disable_not_found_message(void);
306fa1
 
306fa1
 unsigned int conf_amd_mount_section_exists(const char *);
306fa1
+char **conf_amd_get_mount_paths(void);
306fa1
 char *conf_amd_get_arch(void);
306fa1
 char *conf_amd_get_karch(void);
306fa1
 char *conf_amd_get_os(void);
306fa1
--- autofs-5.0.7.orig/lib/defaults.c
306fa1
+++ autofs-5.0.7/lib/defaults.c
306fa1
@@ -763,6 +763,81 @@ static struct conf_option *conf_lookup(c
306fa1
 	return co;
306fa1
 }
306fa1
 
306fa1
+static char **conf_enumerate_amd_mount_sections(void)
306fa1
+{
306fa1
+	struct conf_option *this;
306fa1
+	unsigned int count;
306fa1
+	char **paths;
306fa1
+	char *last;
306fa1
+	int i, j;
306fa1
+
306fa1
+	last = NULL;
306fa1
+	count = 0;
306fa1
+	for (i = 0; i < CFG_TABLE_SIZE; i++) {
306fa1
+		if (!config->hash[i])
306fa1
+			continue;
306fa1
+
306fa1
+		this = config->hash[i];
306fa1
+		while (this) {
306fa1
+			/* Only amd mount section names begin with '/' */
306fa1
+			if (*this->section != '/') {
306fa1
+				this = this->next;
306fa1
+				continue;
306fa1
+			}
306fa1
+
306fa1
+			if (!last ||
306fa1
+			   strcmp(this->section, last))
306fa1
+				count ++;
306fa1
+			last = this->section;
306fa1
+			this = this->next;
306fa1
+		}
306fa1
+	}
306fa1
+
306fa1
+	if (!count)
306fa1
+		return NULL;
306fa1
+
306fa1
+	paths = (char **) malloc(((count + 1) * sizeof(char *)));
306fa1
+	if (!paths)
306fa1
+		return NULL;
306fa1
+	memset(paths, 0, ((count + 1) * sizeof(char *)));
306fa1
+
306fa1
+	last = NULL;
306fa1
+	j = 0;
306fa1
+
306fa1
+	for (i = 0; i < CFG_TABLE_SIZE; i++) {
306fa1
+		if (!config->hash[i])
306fa1
+			continue;
306fa1
+
306fa1
+		this = config->hash[i];
306fa1
+		while (this) {
306fa1
+			/* Only amd mount section names begin with '/' */
306fa1
+			if (*this->section != '/') {
306fa1
+				this = this->next;
306fa1
+				continue;
306fa1
+			}
306fa1
+
306fa1
+			if (!last ||
306fa1
+			    strcmp(this->section, last)) {
306fa1
+				char *path = strdup(this->section);
306fa1
+				if (!path)
306fa1
+					goto fail;
306fa1
+				paths[j++] = path;
306fa1
+			}
306fa1
+			last = this->section;
306fa1
+			this = this->next;
306fa1
+		}
306fa1
+	}
306fa1
+
306fa1
+	return paths;
306fa1
+
306fa1
+fail:
306fa1
+	i = 0;
306fa1
+	while (paths[i])
306fa1
+		free(paths[i++]);
306fa1
+	free(paths);
306fa1
+	return NULL;
306fa1
+}
306fa1
+
306fa1
 static unsigned int conf_section_exists(const char *section)
306fa1
 {
306fa1
 	struct conf_option *co;
306fa1
@@ -1758,6 +1833,11 @@ unsigned int conf_amd_mount_section_exis
306fa1
 	return conf_section_exists(section);
306fa1
 }
306fa1
 
306fa1
+char **conf_amd_get_mount_paths(void)
306fa1
+{
306fa1
+	return conf_enumerate_amd_mount_sections();
306fa1
+}
306fa1
+
306fa1
 char *conf_amd_get_arch(void)
306fa1
 {
306fa1
 	return conf_get_string(amd_gbl_sec, NAME_AMD_ARCH);