aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIan Kent <raven@themaw.net>2023-03-15 14:21:04 +0800
committerIan Kent <raven@themaw.net>2023-05-24 10:15:56 +0800
commit4d72c37600d3836ccacb984e36444a184bc6b7ea (patch)
tree1ce66555ac036b1e90198b773848485f2db8d4a9
parent33cd53e235bcf03d9f6103794676d259c0e26ea6 (diff)
downloadautofs-4d72c37600d3836ccacb984e36444a184bc6b7ea.tar.gz
autofs-5.1.8 - remove redundant stat from do_mount_direct()
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>
-rw-r--r--CHANGELOG1
-rw-r--r--daemon/direct.c10
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);
}