[PATCH v2025.09.y 38/49] fs: fix automount when last filename component is a automountpoint
Ahmad Fatoum
a.fatoum at pengutronix.de
Fri Dec 19 01:21:14 PST 2025
From: Sascha Hauer <s.hauer at pengutronix.de>
When opening a directory in openat() as indicated with the O_DIRECTORY
flag, pass the LOOKUP_DIRECTOY flag to filename_lookup() to make sure
the target is actually a directory. By doing this we can skip the check
afterwards.
filename_lookup() only triggers the automount on the last component when
the LOOKUP_DIRECTORY flag is set, so with this change when /mnt/mmc2.3/
is a automountpoint a
stat /mnt/mmc2.3/
now triggers automounting. This also fixes tab completion with
"ls /mnt/mmc2.3/<tab>" which previously didn't trigger autmounting.
Fixes: a1da0079d1 ("fs: implement opendir in terms of fdopendir")
Reviewed-by: Ahmad Fatoum <a.fatoum at pengutronix.de>
Link: https://lore.barebox.org/20251202092256.1565823-1-s.hauer@pengutronix.de
Signed-off-by: Sascha Hauer <s.hauer at pengutronix.de>
(cherry picked from commit 500df27eb054f86ce232c5bb30c3a7ea8f771e61)
Signed-off-by: Ahmad Fatoum <a.fatoum at pengutronix.de>
---
fs/fs.c | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/fs/fs.c b/fs/fs.c
index 54bd35786857..3eaf9084d096 100644
--- a/fs/fs.c
+++ b/fs/fs.c
@@ -2606,7 +2606,12 @@ int openat(int dirfd, const char *pathname, int flags)
}
if (!(flags & O_CREAT) || error == -EEXIST) {
- error = filename_lookup(dirfd, getname(pathname), LOOKUP_FOLLOW, &path);
+ unsigned f = LOOKUP_FOLLOW;
+
+ if (flags & O_DIRECTORY)
+ f |= LOOKUP_DIRECTORY;
+
+ error = filename_lookup(dirfd, getname(pathname), f, &path);
dentry = path.dentry;
}
@@ -2636,9 +2641,6 @@ int openat(int dirfd, const char *pathname, int flags)
}
flags |= O_DIRECTORY;
- } else if (flags & O_DIRECTORY) {
- error = -ENOTDIR;
- goto out1;
}
inode = d_inode(dentry);
--
2.47.3
More information about the barebox
mailing list