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

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