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

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