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

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