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

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