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

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