autofs-5.1.8 - remove redundant stat from do_mount_direct()

From: Ian Kent <raven@themaw.net>

In do_mount_direct() a stat() call is used to check mount point
attributes but the fstat() of the ioctlfd is for the same path so
the lower overhead fstat() call can be used to do these checks as
well.

Signed-off-by: Ian Kent <raven@themaw.net>
---
 CHANGELOG       |    1 +
 daemon/direct.c |   10 +---------
 2 files changed, 2 insertions(+), 9 deletions(-)

diff --git a/CHANGELOG b/CHANGELOG
index 9f15e8ae..c508883d 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -78,6 +78,7 @@
 - continue expire immediately after submount check.
 - eliminate realpath from mount of submount.
 - eliminate root param from autofs mount and umount.
+- remove redundant fstat from do_mount_direct().
 
 19/10/2021 autofs-5.1.8
 - add xdr_exports().
diff --git a/daemon/direct.c b/daemon/direct.c
index f4988543..6de45f8d 100644
--- a/daemon/direct.c
+++ b/daemon/direct.c
@@ -1203,19 +1203,11 @@ static void *do_mount_direct(void *arg)
 	}
 
 	status = fstat(mt.ioctlfd, &st);
-	if (status == -1) {
-		error(ap->logopt,
-		      "can't stat direct mount trigger %s", mt.name);
-		mt.status = -ENOENT;
-		pthread_setcancelstate(state, NULL);
-		pthread_exit(NULL);
-	}
-
-	status = stat(mt.name, &st);
 	if (status != 0 || !S_ISDIR(st.st_mode) || st.st_dev != mt.dev) {
 		error(ap->logopt,
 		     "direct trigger not valid or already mounted %s",
 		     mt.name);
+		mt.status = -EINVAL;
 		pthread_setcancelstate(state, NULL);
 		pthread_exit(NULL);
 	}
