Blame SOURCES/autofs-5.0.9-amd-lookup-add-lofs-ext-and-xfs-fs-types.patch

6bbd11
autofs-5.0.9 - amd lookup add fs types lofs, ext, and xfs
6bbd11
6bbd11
From: Ian Kent <raven@themaw.net>
6bbd11
6bbd11
6bbd11
---
6bbd11
 include/parse_amd.h |    9 +++++++++
6bbd11
 modules/amd_parse.y |   13 +++++++++++++
6bbd11
 modules/amd_tok.l   |    4 +++-
6bbd11
 modules/parse_amd.c |   50 ++++++++++++++++++++++++++++++++++++++++++++++++++
6bbd11
 4 files changed, 75 insertions(+), 1 deletion(-)
6bbd11
6bbd11
diff --git a/include/parse_amd.h b/include/parse_amd.h
6bbd11
index a8521b5..4015e9f 100644
6bbd11
--- a/include/parse_amd.h
6bbd11
+++ b/include/parse_amd.h
6bbd11
@@ -20,6 +20,14 @@
6bbd11
 #define AMD_MOUNT_TYPE_NFS	0x00000002
6bbd11
 #define AMD_MOUNT_TYPE_LINK	0x00000004
6bbd11
 #define AMD_MOUNT_TYPE_HOST	0x00000008
6bbd11
+#define AMD_MOUNT_TYPE_NFSL	0x00000010
6bbd11
+#define AMD_MOUNT_TYPE_NFSX	0x00000020
6bbd11
+#define AMD_MOUNT_TYPE_LINKX	0x00000040
6bbd11
+#define AMD_MOUNT_TYPE_LOFS	0x00000080
6bbd11
+#define AMD_MOUNT_TYPE_EXT	0x00000100
6bbd11
+#define AMD_MOUNT_TYPE_XFS	0x00000200
6bbd11
+#define AMD_MOUNT_TYPE_JFS	0x00000400
6bbd11
+#define AMD_MOUNT_TYPE_CACHEFS	0x00000800
6bbd11
 #define AMD_MOUNT_TYPE_MASK	0x0000ffff
6bbd11
 
6bbd11
 #define AMD_ENTRY_CUT		0x00010000
6bbd11
@@ -38,6 +46,7 @@ struct amd_entry {
6bbd11
 	char *fs;
6bbd11
 	char *rhost;
6bbd11
 	char *rfs;
6bbd11
+	char *dev;
6bbd11
 	char *opts;
6bbd11
 	char *addopts;
6bbd11
 	char *remopts;
6bbd11
diff --git a/modules/amd_parse.y b/modules/amd_parse.y
6bbd11
index 71fd569..cd69c49 100644
6bbd11
--- a/modules/amd_parse.y
6bbd11
+++ b/modules/amd_parse.y
6bbd11
@@ -248,6 +248,17 @@ option_assignment: MAP_OPTION OPTION_ASSIGN FS_TYPE
6bbd11
 		} else if (!strcmp($3, "host")) {
6bbd11
 			entry.flags |= AMD_MOUNT_TYPE_HOST;
6bbd11
 			entry.type = amd_strdup($3);
6bbd11
+		} else if (!strcmp($3, "lofs")) {
6bbd11
+			entry.flags |= AMD_MOUNT_TYPE_LOFS;
6bbd11
+			entry.type = amd_strdup("bind");
6bbd11
+		} else if (!strcmp($3, "xfs")) {
6bbd11
+			entry.flags |= AMD_MOUNT_TYPE_XFS;
6bbd11
+			entry.type = amd_strdup($3);
6bbd11
+		} else if (!strcmp($3, "ext2") ||
6bbd11
+			   !strcmp($3, "ext3") ||
6bbd11
+			   !strcmp($3, "ext4")) {
6bbd11
+			entry.flags |= AMD_MOUNT_TYPE_EXT;
6bbd11
+			entry.type = amd_strdup($3);
6bbd11
 		} else {
6bbd11
 			amd_notify($1);
6bbd11
 			YYABORT;
6bbd11
@@ -291,6 +302,8 @@ option_assignment: MAP_OPTION OPTION_ASSIGN FS_TYPE
6bbd11
 			entry.rhost = amd_strdup($3);
6bbd11
 		else if (!strcmp($1, "rfs"))
6bbd11
 			entry.rfs = amd_strdup($3);
6bbd11
+		else if (!strcmp($1, "dev"))
6bbd11
+			entry.dev = amd_strdup($3);
6bbd11
 		else {
6bbd11
 			amd_notify($1);
6bbd11
 			YYABORT;
6bbd11
diff --git a/modules/amd_tok.l b/modules/amd_tok.l
6bbd11
index cea9ea5..fdc8899 100644
6bbd11
--- a/modules/amd_tok.l
6bbd11
+++ b/modules/amd_tok.l
6bbd11
@@ -98,7 +98,9 @@ MAPOPT		(fs|type|maptype|pref|sublink|delay)
6bbd11
 MNTOPT		(opts|addopts|remopts)
6bbd11
 FSOPTS		(rhost|rfs|dev|cachedir)
6bbd11
 MAPTYPE		(file|nis|nisplus|ldap|hesiod|exec|ndbm|passwd|union)
6bbd11
-FSTYPE		(auto|nfs|link|host|nfsx|ufs|xfs|efs)
6bbd11
+FSTYPE_LOCAL	(link|linkx|lofs|ext2|ext3|ext4|xfs|jfs|cachefs)
6bbd11
+FSTYPE_NET	(nfs|nfsx|nfsl|host)
6bbd11
+FSTYPE		(auto|program|direct|{FSTYPE_LOCAL}|{FSTYPE_NET})
6bbd11
 
6bbd11
 OSSEL		(arch|karch|os|osver|full_os|vendor)
6bbd11
 HSTSEL		(host|hostd|domain|byte|cluster)
6bbd11
diff --git a/modules/parse_amd.c b/modules/parse_amd.c
6bbd11
index 4322479..e27a195 100644
6bbd11
--- a/modules/parse_amd.c
6bbd11
+++ b/modules/parse_amd.c
6bbd11
@@ -598,6 +598,12 @@ static void update_with_defaults(struct amd_entry *defaults,
6bbd11
 		}
6bbd11
 	}
6bbd11
 
6bbd11
+	if (!entry->dev && defaults->dev) {
6bbd11
+		tmp = strdup(defaults->dev);
6bbd11
+		if (tmp)
6bbd11
+			entry->dev = tmp;
6bbd11
+	}
6bbd11
+
6bbd11
 	if (!entry->opts && defaults->opts) {
6bbd11
 		tmp = merge_options(defaults->opts, entry->opts);
6bbd11
 		if (tmp)
6bbd11
@@ -949,6 +955,35 @@ out:
6bbd11
 	return ret;
6bbd11
 }
6bbd11
 
6bbd11
+static int do_generic_mount(struct autofs_point *ap, const char *name,
6bbd11
+			    struct amd_entry *entry, const char *target,
6bbd11
+			    unsigned int flags)
6bbd11
+{
6bbd11
+	int ret = 0;
6bbd11
+
6bbd11
+	if (!entry->sublink) {
6bbd11
+		ret = do_mount(ap, ap->path, name, strlen(name),
6bbd11
+			       target, entry->type, entry->opts);
6bbd11
+	} else {
6bbd11
+		/*
6bbd11
+		 * Careful, external mounts may get mounted
6bbd11
+		 * multiple times since they are outside of
6bbd11
+		 * the automount filesystem.
6bbd11
+		 */
6bbd11
+		if (!is_mounted(_PATH_MOUNTED, entry->fs, MNTS_REAL)) {
6bbd11
+			ret = do_mount(ap, entry->fs, "/", 1,
6bbd11
+				       target, entry->type, entry->opts);
6bbd11
+			if (ret)
6bbd11
+				goto out;
6bbd11
+		}
6bbd11
+		/* We might be using an external mount */
6bbd11
+		ext_mount_add(&entry->ext_mount, entry->fs);
6bbd11
+		ret = do_link_mount(ap, name, entry, flags);
6bbd11
+	}
6bbd11
+out:
6bbd11
+	return ret;
6bbd11
+}
6bbd11
+
6bbd11
 static int do_nfs_mount(struct autofs_point *ap, const char *name,
6bbd11
 			struct amd_entry *entry, unsigned int flags)
6bbd11
 {
6bbd11
@@ -1024,6 +1059,15 @@ static int amd_mount(struct autofs_point *ap, const char *name,
6bbd11
 		ret = do_auto_mount(ap, name, entry, flags);
6bbd11
 		break;
6bbd11
 
6bbd11
+	case AMD_MOUNT_TYPE_LOFS:
6bbd11
+		ret = do_generic_mount(ap, name, entry, entry->rfs, flags);
6bbd11
+		break;
6bbd11
+
6bbd11
+	case AMD_MOUNT_TYPE_EXT:
6bbd11
+	case AMD_MOUNT_TYPE_XFS:
6bbd11
+		ret = do_generic_mount(ap, name, entry, entry->dev, flags);
6bbd11
+		break;
6bbd11
+
6bbd11
 	case AMD_MOUNT_TYPE_NFS:
6bbd11
 		ret = do_nfs_mount(ap, name, entry, flags);
6bbd11
 		break;
6bbd11
@@ -1260,6 +1304,12 @@ static struct amd_entry *dup_defaults_entry(struct amd_entry *defaults)
6bbd11
 			entry->rhost = tmp;
6bbd11
 	}
6bbd11
 
6bbd11
+	if (defaults->dev) {
6bbd11
+		tmp = strdup(defaults->dev);
6bbd11
+		if (tmp)
6bbd11
+			entry->dev = tmp;
6bbd11
+	}
6bbd11
+
6bbd11
 	if (defaults->opts) {
6bbd11
 		tmp = strdup(defaults->opts);
6bbd11
 		if (tmp)