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

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