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

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