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

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