Blame SOURCES/autofs-5.0.9-amd-lookup-add-nfsl-and-linkx-fs-types.patch

4d476f
autofs-5.0.9 - amd lookup add nfsl and linkx fs types
4d476f
4d476f
From: Ian Kent <raven@themaw.net>
4d476f
4d476f
4d476f
---
4d476f
 modules/amd_parse.y |    8 ++++++--
4d476f
 modules/parse_amd.c |   54 +++++++++++++++++++++++++++++++++++++++++++++++++++
4d476f
 2 files changed, 60 insertions(+), 2 deletions(-)
4d476f
4d476f
diff --git a/modules/amd_parse.y b/modules/amd_parse.y
4d476f
index 77adbe5..1d4a0a3 100644
4d476f
--- a/modules/amd_parse.y
4d476f
+++ b/modules/amd_parse.y
4d476f
@@ -246,9 +246,15 @@ option_assignment: MAP_OPTION OPTION_ASSIGN FS_TYPE
4d476f
 			   !strcmp($3, "nfs4")) {
4d476f
 			entry.flags |= AMD_MOUNT_TYPE_NFS;
4d476f
 			entry.type = amd_strdup($3);
4d476f
+		} else if (!strcmp($3, "nfsl")) {
4d476f
+			entry.flags |= AMD_MOUNT_TYPE_NFSL;
4d476f
+			entry.type = amd_strdup($3);
4d476f
 		} else if (!strcmp($3, "link")) {
4d476f
 			entry.flags |= AMD_MOUNT_TYPE_LINK;
4d476f
 			entry.type = amd_strdup($3);
4d476f
+		} else if (!strcmp($3, "linkx")) {
4d476f
+			entry.flags |= AMD_MOUNT_TYPE_LINKX;
4d476f
+			entry.type = amd_strdup($3);
4d476f
 		} else if (!strcmp($3, "host")) {
4d476f
 			entry.flags |= AMD_MOUNT_TYPE_HOST;
4d476f
 			entry.type = amd_strdup($3);
4d476f
@@ -264,9 +270,7 @@ option_assignment: MAP_OPTION OPTION_ASSIGN FS_TYPE
4d476f
 			entry.flags |= AMD_MOUNT_TYPE_EXT;
4d476f
 			entry.type = amd_strdup($3);
4d476f
 		} else if (!strcmp($3, "jfs") ||
4d476f
-			   !strcmp($3, "linkx") ||
4d476f
 			   !strcmp($3, "nfsx") ||
4d476f
-			   !strcmp($3, "nfsl") ||
4d476f
 			   !strcmp($3, "program") ||
4d476f
 			   !strcmp($3, "lustre") ||
4d476f
 			   !strcmp($3, "direct")) {
4d476f
diff --git a/modules/parse_amd.c b/modules/parse_amd.c
4d476f
index 4cebce8..7e04beb 100644
4d476f
--- a/modules/parse_amd.c
4d476f
+++ b/modules/parse_amd.c
4d476f
@@ -955,6 +955,23 @@ out:
4d476f
 	return ret;
4d476f
 }
4d476f
 
4d476f
+static int do_linkx_mount(struct autofs_point *ap, const char *name,
4d476f
+			  struct amd_entry *entry, unsigned int flags)
4d476f
+{
4d476f
+	struct stat st;
4d476f
+	char *target;
4d476f
+
4d476f
+	if (entry->sublink)
4d476f
+		target = entry->sublink;
4d476f
+	else
4d476f
+		target = entry->fs;
4d476f
+
4d476f
+	if (lstat(target, &st) < 0)
4d476f
+		return errno;
4d476f
+
4d476f
+	return do_link_mount(ap, name, entry, flags);
4d476f
+}
4d476f
+
4d476f
 static int do_generic_mount(struct autofs_point *ap, const char *name,
4d476f
 			    struct amd_entry *entry, const char *target,
4d476f
 			    unsigned int flags)
4d476f
@@ -1020,6 +1037,35 @@ out:
4d476f
 	return ret;
4d476f
 }
4d476f
 
4d476f
+static int do_nfsl_mount(struct autofs_point *ap, const char *name,
4d476f
+			 struct amd_entry *entry, struct substvar *sv,
4d476f
+			 unsigned int flags)
4d476f
+{
4d476f
+	const struct substvar *host, *hostd;
4d476f
+	struct stat st;
4d476f
+	char *target;
4d476f
+
4d476f
+	host = macro_findvar(sv, "host", 4);
4d476f
+	if (!host)
4d476f
+		return do_nfs_mount(ap, name, entry, flags);
4d476f
+	hostd = macro_findvar(sv, "hostd", 5);
4d476f
+	if (!hostd || !*hostd->val)
4d476f
+		return do_nfs_mount(ap, name, entry, flags);
4d476f
+
4d476f
+	if (entry->sublink)
4d476f
+		target = entry->sublink;
4d476f
+	else
4d476f
+		target = entry->fs;
4d476f
+
4d476f
+	if (strcasecmp(host->val, entry->rhost) ||
4d476f
+	    strcasecmp(hostd->val, entry->rhost))
4d476f
+		return do_nfs_mount(ap, name, entry, flags);
4d476f
+	else if (lstat(target, &st) < 0)
4d476f
+		return do_nfs_mount(ap, name, entry, flags);
4d476f
+
4d476f
+	return do_link_mount(ap, name, entry, flags);
4d476f
+}
4d476f
+
4d476f
 static int do_host_mount(struct autofs_point *ap, const char *name,
4d476f
 			 struct amd_entry *entry, struct map_source *source,
4d476f
 			 unsigned int flags)
4d476f
@@ -1078,10 +1124,18 @@ static int amd_mount(struct autofs_point *ap, const char *name,
4d476f
 		ret = do_nfs_mount(ap, name, entry, flags);
4d476f
 		break;
4d476f
 
4d476f
+	case AMD_MOUNT_TYPE_NFSL:
4d476f
+		ret = do_nfsl_mount(ap, name, entry, sv, flags);
4d476f
+		break;
4d476f
+
4d476f
 	case AMD_MOUNT_TYPE_LINK:
4d476f
 		ret = do_link_mount(ap, name, entry, flags);
4d476f
 		break;
4d476f
 
4d476f
+	case AMD_MOUNT_TYPE_LINKX:
4d476f
+		ret = do_linkx_mount(ap, name, entry, flags);
4d476f
+		break;
4d476f
+
4d476f
 	case AMD_MOUNT_TYPE_HOST:
4d476f
 		ret = do_host_mount(ap, name, entry, source, flags);
4d476f
 		break;