Blame SOURCES/autofs-5.1.8-fix-kernel-mount-status-notification.patch

b07c2e
autofs-5.1.8 - fix kernel mount status notification
b07c2e
b07c2e
From: Ian Kent <raven@themaw.net>
b07c2e
b07c2e
The status return for attempted mount notification is not done
b07c2e
correctly in some cases leading to a status being sent to the
b07c2e
kernel multiple times or the send causing an error.
b07c2e
b07c2e
We must send a status to the kernel but it needs to be the correct
b07c2e
one. It definitely shouldn't be sent twice for the same mount attempt
b07c2e
and shouldn't be failing.
b07c2e
b07c2e
Signed-off-by: Ian Kent <raven@themaw.net>
b07c2e
---
b07c2e
 CHANGELOG         |    1 +
b07c2e
 daemon/direct.c   |   19 +++++++++++--------
b07c2e
 daemon/indirect.c |   19 +++++++++++--------
b07c2e
 3 files changed, 23 insertions(+), 16 deletions(-)
b07c2e
b07c2e
--- autofs-5.1.4.orig/CHANGELOG
b07c2e
+++ autofs-5.1.4/CHANGELOG
b07c2e
@@ -78,6 +78,7 @@
b07c2e
 - fix empty mounts list return from unlink_mount_tree().
b07c2e
 - fix nonstrict offset mount fail handling.
b07c2e
 - remove intr hosts map mount option.
b07c2e
+- fix kernel mount status notification.
b07c2e
 
b07c2e
 xx/xx/2018 autofs-5.1.5
b07c2e
 - fix flag file permission.
b07c2e
--- autofs-5.1.4.orig/daemon/direct.c
b07c2e
+++ autofs-5.1.4/daemon/direct.c
b07c2e
@@ -1143,12 +1143,18 @@ int handle_packet_expire_direct(struct a
b07c2e
 	return 0;
b07c2e
 }
b07c2e
 
b07c2e
-static void mount_send_fail(void *arg)
b07c2e
+static void mount_send_status(void *arg)
b07c2e
 {
b07c2e
 	struct ioctl_ops *ops = get_ioctl_ops();
b07c2e
 	struct pending_args *mt = arg;
b07c2e
 	struct autofs_point *ap = mt->ap;
b07c2e
-	ops->send_fail(ap->logopt, mt->ioctlfd, mt->wait_queue_token, -ENOENT);
b07c2e
+
b07c2e
+	if (mt->status)
b07c2e
+		ops->send_fail(ap->logopt, mt->ioctlfd,
b07c2e
+			       mt->wait_queue_token, mt->status);
b07c2e
+	else
b07c2e
+		ops->send_ready(ap->logopt,
b07c2e
+				mt->ioctlfd, mt->wait_queue_token);
b07c2e
 	ops->close(ap->logopt, mt->ioctlfd);
b07c2e
 }
b07c2e
 
b07c2e
@@ -1177,7 +1183,8 @@ static void *do_mount_direct(void *arg)
b07c2e
 
b07c2e
 	pending_mutex_unlock(args);
b07c2e
 
b07c2e
-	pthread_cleanup_push(mount_send_fail, &mt;;
b07c2e
+	mt.status = 0;
b07c2e
+	pthread_cleanup_push(mount_send_status, &mt;;
b07c2e
 
b07c2e
 	pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &state);
b07c2e
 
b07c2e
@@ -1191,9 +1198,7 @@ static void *do_mount_direct(void *arg)
b07c2e
 	if (status == -1) {
b07c2e
 		error(ap->logopt,
b07c2e
 		      "can't stat direct mount trigger %s", mt.name);
b07c2e
-		ops->send_fail(ap->logopt,
b07c2e
-			       mt.ioctlfd, mt.wait_queue_token, -ENOENT);
b07c2e
-		ops->close(ap->logopt, mt.ioctlfd);
b07c2e
+		mt.status = -ENOENT;
b07c2e
 		pthread_setcancelstate(state, NULL);
b07c2e
 		pthread_exit(NULL);
b07c2e
 	}
b07c2e
@@ -1203,8 +1208,6 @@ static void *do_mount_direct(void *arg)
b07c2e
 		error(ap->logopt,
b07c2e
 		     "direct trigger not valid or already mounted %s",
b07c2e
 		     mt.name);
b07c2e
-		ops->send_ready(ap->logopt, mt.ioctlfd, mt.wait_queue_token);
b07c2e
-		ops->close(ap->logopt, mt.ioctlfd);
b07c2e
 		pthread_setcancelstate(state, NULL);
b07c2e
 		pthread_exit(NULL);
b07c2e
 	}
b07c2e
--- autofs-5.1.4.orig/daemon/indirect.c
b07c2e
+++ autofs-5.1.4/daemon/indirect.c
b07c2e
@@ -674,13 +674,18 @@ int handle_packet_expire_indirect(struct
b07c2e
 	return 0;
b07c2e
 }
b07c2e
 
b07c2e
-static void mount_send_fail(void *arg)
b07c2e
+static void mount_send_status(void *arg)
b07c2e
 {
b07c2e
 	struct ioctl_ops *ops = get_ioctl_ops();
b07c2e
 	struct pending_args *mt = arg;
b07c2e
 	struct autofs_point *ap = mt->ap;
b07c2e
-	ops->send_fail(ap->logopt,
b07c2e
-		       ap->ioctlfd, mt->wait_queue_token, -ENOENT);
b07c2e
+
b07c2e
+	if (mt->status)
b07c2e
+		ops->send_fail(ap->logopt, ap->ioctlfd,
b07c2e
+			       mt->wait_queue_token, mt->status);
b07c2e
+	else
b07c2e
+		ops->send_ready(ap->logopt,
b07c2e
+				ap->ioctlfd, mt->wait_queue_token);
b07c2e
 }
b07c2e
 
b07c2e
 static void *do_mount_indirect(void *arg)
b07c2e
@@ -709,7 +714,8 @@ static void *do_mount_indirect(void *arg
b07c2e
 
b07c2e
 	pending_mutex_unlock(args);
b07c2e
 
b07c2e
-	pthread_cleanup_push(mount_send_fail, &mt;;
b07c2e
+	mt.status = 0;
b07c2e
+	pthread_cleanup_push(mount_send_status, &mt;;
b07c2e
 
b07c2e
 	pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &state);
b07c2e
 
b07c2e
@@ -722,9 +728,7 @@ static void *do_mount_indirect(void *arg
b07c2e
 	len = ncat_path(buf, sizeof(buf), ap->path, mt.name, mt.len);
b07c2e
 	if (!len) {
b07c2e
 		crit(ap->logopt, "path to be mounted is to long");
b07c2e
-		ops->send_fail(ap->logopt,
b07c2e
-			       ap->ioctlfd, mt.wait_queue_token,
b07c2e
-			      -ENAMETOOLONG);
b07c2e
+		mt.status = -ENAMETOOLONG;
b07c2e
 		pthread_setcancelstate(state, NULL);
b07c2e
 		pthread_exit(NULL);
b07c2e
 	}
b07c2e
@@ -733,7 +737,6 @@ static void *do_mount_indirect(void *arg
b07c2e
 	if (status != -1 && !(S_ISDIR(st.st_mode) && st.st_dev == mt.dev)) {
b07c2e
 		error(ap->logopt,
b07c2e
 		      "indirect trigger not valid or already mounted %s", buf);
b07c2e
-		ops->send_ready(ap->logopt, ap->ioctlfd, mt.wait_queue_token);
b07c2e
 		pthread_setcancelstate(state, NULL);
b07c2e
 		pthread_exit(NULL);
b07c2e
 	}