Blame SOURCES/autofs-5.0.9-amd-lookup-add-ufs-fs-type.patch

4d476f
autofs-5.0.9 - amd lookup add ufs fs type
4d476f
4d476f
From: Ian Kent <ikent@redhat.com>
4d476f
4d476f
Completely overlooked mount type ufs, which should be the
4d476f
system default filesystem.
4d476f
4d476f
There's no simple way to determine what the system default
4d476f
filesystem is and am-utils needs to be continually updated
4d476f
to do this and can easily get it wrong anyway.
4d476f
4d476f
A better approach is to use a configuration entry and set
4d476f
it to be what it usually is in am-utils, allowing the user
4d476f
to set it to what they would like it to be.
4d476f
---
4d476f
 include/defaults.h             |    2 ++
4d476f
 include/parse_amd.h            |    9 +++++----
4d476f
 lib/defaults.c                 |   10 ++++++++++
4d476f
 man/autofs.conf.5.in           |    9 +++++++++
4d476f
 modules/amd_parse.y            |    3 +++
4d476f
 modules/amd_tok.l              |    2 +-
4d476f
 modules/parse_amd.c            |   21 +++++++++++++++++++++
4d476f
 redhat/autofs.conf.default.in  |    9 +++++++++
4d476f
 samples/autofs.conf.default.in |    9 +++++++++
4d476f
 9 files changed, 69 insertions(+), 5 deletions(-)
4d476f
4d476f
diff --git a/include/defaults.h b/include/defaults.h
4d476f
index 033acaf..6ca20d0 100644
4d476f
--- a/include/defaults.h
4d476f
+++ b/include/defaults.h
4d476f
@@ -130,6 +130,7 @@
4d476f
 #define DEFAULT_AMD_UMOUNT_ON_EXIT		"yes"
4d476f
 #define DEFAULT_AMD_USE_TCPWRAPPERS		DEFAULT_AMD_NULL_VALUE
4d476f
 #define DEFAULT_AMD_VENDOR			"unknown"
4d476f
+#define DEFAULT_AMD_LINUX_UFS_MOUNT_TYPE	"ext3"
4d476f
 
4d476f
 #ifdef WITH_LDAP
4d476f
 struct ldap_schema;
4d476f
@@ -184,6 +185,7 @@ char *conf_amd_get_map_defaults(const char *);
4d476f
 char *conf_amd_get_map_type(const char *);
4d476f
 char *conf_amd_get_search_path(const char *);
4d476f
 unsigned int conf_amd_get_dismount_interval(const char *);
4d476f
+char *conf_amd_get_linux_ufs_mount_type(void);
4d476f
 unsigned long conf_amd_get_flags(const char *);
4d476f
 
4d476f
 #endif
4d476f
diff --git a/include/parse_amd.h b/include/parse_amd.h
4d476f
index 401aadb..313edd5 100644
4d476f
--- a/include/parse_amd.h
4d476f
+++ b/include/parse_amd.h
4d476f
@@ -25,10 +25,11 @@
4d476f
 #define AMD_MOUNT_TYPE_LINKX	0x00000040
4d476f
 #define AMD_MOUNT_TYPE_LOFS	0x00000080
4d476f
 #define AMD_MOUNT_TYPE_EXT	0x00000100
4d476f
-#define AMD_MOUNT_TYPE_XFS	0x00000200
4d476f
-#define AMD_MOUNT_TYPE_JFS	0x00000400
4d476f
-#define AMD_MOUNT_TYPE_CACHEFS	0x00000800
4d476f
-#define AMD_MOUNT_TYPE_CDFS	0x00001000
4d476f
+#define AMD_MOUNT_TYPE_UFS	0x00000200
4d476f
+#define AMD_MOUNT_TYPE_XFS	0x00000400
4d476f
+#define AMD_MOUNT_TYPE_JFS	0x00000800
4d476f
+#define AMD_MOUNT_TYPE_CACHEFS	0x00001000
4d476f
+#define AMD_MOUNT_TYPE_CDFS	0x00002000
4d476f
 #define AMD_MOUNT_TYPE_MASK	0x0000ffff
4d476f
 
4d476f
 #define AMD_ENTRY_CUT		0x00010000
4d476f
diff --git a/lib/defaults.c b/lib/defaults.c
4d476f
index bdaba67..3fa2216 100644
4d476f
--- a/lib/defaults.c
4d476f
+++ b/lib/defaults.c
4d476f
@@ -136,6 +136,7 @@
4d476f
 #define NAME_AMD_UMOUNT_ON_EXIT			"unmount_on_exit"
4d476f
 #define NAME_AMD_USE_TCPWRAPPERS		"use_tcpwrappers"
4d476f
 #define NAME_AMD_VENDOR				"vendor"
4d476f
+#define NAME_AMD_LINUX_UFS_MOUNT_TYPE		"linux_ufs_mount_type"
4d476f
 
4d476f
 /* Status returns */
4d476f
 #define CFG_OK		0x0000
4d476f
@@ -543,6 +544,10 @@ static int conf_load_amd_defaults(void)
4d476f
 	if (ret == CFG_FAIL)
4d476f
 		goto error;
4d476f
 
4d476f
+	ret = conf_update(sec, NAME_AMD_LINUX_UFS_MOUNT_TYPE,
4d476f
+			  DEFAULT_AMD_LINUX_UFS_MOUNT_TYPE, CONF_NONE);
4d476f
+	if (ret == CFG_FAIL)
4d476f
+		goto error;
4d476f
 	return 1;
4d476f
 
4d476f
 error:
4d476f
@@ -1706,6 +1711,11 @@ unsigned int conf_amd_get_dismount_interval(const char *section)
4d476f
 	return (unsigned int) tmp;
4d476f
 }
4d476f
 
4d476f
+char *conf_amd_get_linux_ufs_mount_type(void)
4d476f
+{
4d476f
+	return conf_get_string(amd_gbl_sec, NAME_AMD_LINUX_UFS_MOUNT_TYPE);
4d476f
+}
4d476f
+
4d476f
 unsigned long conf_amd_get_flags(const char *section)
4d476f
 {
4d476f
 	const char *amd = amd_gbl_sec;
4d476f
diff --git a/man/autofs.conf.5.in b/man/autofs.conf.5.in
4d476f
index f25a918..c959b52 100644
4d476f
--- a/man/autofs.conf.5.in
4d476f
+++ b/man/autofs.conf.5.in
4d476f
@@ -390,6 +390,15 @@ LDAP URIs.
4d476f
 .B hesiod_base
4d476f
 .br
4d476f
 Sets the base name used for hesiod map sources.
4d476f
+.TP
4d476f
+.B linux_ufs_mount_type
4d476f
+.br
4d476f
+This is an aditional configuration option for the autofs amd format
4d476f
+parser implementation.
4d476f
+
4d476f
+There's no simple way to determine what the system default filesystem
4d476f
+is and am-utils needs to be continually updated to do this and can
4d476f
+easily get it wrong ayway. So allow it to be set in the configuration.
4d476f
 .SH EXAMPLE
4d476f
 .sp
4d476f
 .RS +.2i
4d476f
diff --git a/modules/amd_parse.y b/modules/amd_parse.y
4d476f
index 87e3309..8174fb2 100644
4d476f
--- a/modules/amd_parse.y
4d476f
+++ b/modules/amd_parse.y
4d476f
@@ -269,6 +269,9 @@ option_assignment: MAP_OPTION OPTION_ASSIGN FS_TYPE
4d476f
 			   !strcmp($3, "ext4")) {
4d476f
 			entry.flags |= AMD_MOUNT_TYPE_EXT;
4d476f
 			entry.type = amd_strdup($3);
4d476f
+		} else if (!strcmp($3, "ufs")) {
4d476f
+			entry.flags |= AMD_MOUNT_TYPE_UFS;
4d476f
+			entry.type = conf_amd_get_linux_ufs_mount_type();
4d476f
 		} else if (!strcmp($3, "cdfs")) {
4d476f
 			entry.flags |= AMD_MOUNT_TYPE_CDFS;
4d476f
 			entry.type = amd_strdup("iso9660");
4d476f
diff --git a/modules/amd_tok.l b/modules/amd_tok.l
4d476f
index 10b1963..618bc91 100644
4d476f
--- a/modules/amd_tok.l
4d476f
+++ b/modules/amd_tok.l
4d476f
@@ -99,7 +99,7 @@ MNTOPT		(opts|addopts|remopts)
4d476f
 FSOPTS		(rhost|rfs|dev|cachedir|mount|unmount|umount|delay)
4d476f
 CHEOPT		(mapdefault|none|inc|re|regexp|all)
4d476f
 MAPTYPE		(file|nis|nisplus|ldap|hesiod|exec|ndbm|passwd|union)
4d476f
-FSTYPE_LOCAL	(link|linkx|lofs|ext2|ext3|ext4|xfs|jfs|cdfs|cachefs)
4d476f
+FSTYPE_LOCAL	(link|linkx|lofs|ufs|ext2|ext3|ext4|xfs|jfs|cdfs|cachefs)
4d476f
 FSTYPE_NET	(nfs|nfsx|nfsl|host)
4d476f
 FSTYPE		(auto|program|direct|lustre|{FSTYPE_LOCAL}|{FSTYPE_NET})
4d476f
 
4d476f
diff --git a/modules/parse_amd.c b/modules/parse_amd.c
4d476f
index 790f25e..0c708e6 100644
4d476f
--- a/modules/parse_amd.c
4d476f
+++ b/modules/parse_amd.c
4d476f
@@ -1245,6 +1245,22 @@ static unsigned int validate_generic_options(unsigned int logopt,
4d476f
 	return 1;
4d476f
 }
4d476f
 
4d476f
+static unsigned int validate_ufs_fstype(unsigned int logopt,
4d476f
+					struct amd_entry *entry)
4d476f
+{
4d476f
+	const char *type = (const char *) entry->type;
4d476f
+
4d476f
+	if (strcmp(type, "ext") && strcmp(type, "ext2") &&
4d476f
+	    strcmp(type, "ext3") && strcmp(type, "ext4") &&
4d476f
+	    strcmp(type, "xfs") && strcmp(type, "jfs")) {
4d476f
+		error(logopt, MODPREFIX
4d476f
+		      "%s: mount type %s not valid as ufs mount type on Linux",
4d476f
+		      type);
4d476f
+		return 0;
4d476f
+	}
4d476f
+	return 1;
4d476f
+}
4d476f
+
4d476f
 static unsigned int validate_host_options(unsigned int logopt,
4d476f
 					  struct amd_entry *entry)
4d476f
 {
4d476f
@@ -1282,6 +1298,11 @@ static int amd_mount(struct autofs_point *ap, const char *name,
4d476f
 		ret = do_generic_mount(ap, name, entry, entry->rfs, flags);
4d476f
 		break;
4d476f
 
4d476f
+	case AMD_MOUNT_TYPE_UFS:
4d476f
+		if (!validate_ufs_fstype(ap->logopt, entry))
4d476f
+			return 1;
4d476f
+		/* fall through to validate generic options */
4d476f
+
4d476f
 	case AMD_MOUNT_TYPE_EXT:
4d476f
 	case AMD_MOUNT_TYPE_XFS:
4d476f
 	case AMD_MOUNT_TYPE_CDFS:
4d476f
diff --git a/redhat/autofs.conf.default.in b/redhat/autofs.conf.default.in
4d476f
index 1fa951b..8ccd5d6 100644
4d476f
--- a/redhat/autofs.conf.default.in
4d476f
+++ b/redhat/autofs.conf.default.in
4d476f
@@ -306,6 +306,15 @@ mount_nfs_default_protocol = 4
4d476f
 #
4d476f
 # hesiod_base - the base name used for hesiod map sources.
4d476f
 #
4d476f
+# Additional configuration options added:
4d476f
+#
4d476f
+# linux_ufs_mount_type - set the default system filesystem type that's
4d476f
+#	used for mount type ufs. There's no simple way to determine
4d476f
+#	what the system default filesystem is and am-utils needs to
4d476f
+#	be continually updated to do this and can easily get it wrong
4d476f
+#	anyway.
4d476f
+#
4d476f
+#
4d476f
 # Define global options for the amd parser within autofs.
4d476f
 #
4d476f
 [ amd ]
4d476f
diff --git a/samples/autofs.conf.default.in b/samples/autofs.conf.default.in
4d476f
index 7a84566..934e411 100644
4d476f
--- a/samples/autofs.conf.default.in
4d476f
+++ b/samples/autofs.conf.default.in
4d476f
@@ -305,6 +305,15 @@ browse_mode = no
4d476f
 #
4d476f
 # hesiod_base - the base name used for hesiod map sources.
4d476f
 #
4d476f
+# Additional configuration options added:
4d476f
+#
4d476f
+# linux_ufs_mount_type - set the default system filesystem type that's
4d476f
+#	used for mount type ufs. There's no simple way to determine
4d476f
+#	what the system default filesystem is and am-utils needs to
4d476f
+#	be continually updated to do this and can easily get it wrong
4d476f
+#	anyway.
4d476f
+#
4d476f
+#
4d476f
 # Define global options for the amd parser within autofs.
4d476f
 #
4d476f
 [ amd ]