From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: Sascha Hauer <s.hauer@pengutronix.de>,
Barebox List <barebox@lists.infradead.org>
Subject: Re: [PATCH] fs: fix automount when last filename component is a automountpoint
Date: Tue, 2 Dec 2025 10:37:31 +0100 [thread overview]
Message-ID: <a990caa7-38d0-4ff6-9d2c-58f8dde494bd@pengutronix.de> (raw)
In-Reply-To: <20251202092256.1565823-1-s.hauer@pengutronix.de>
Hi,
On 12/2/25 10:22 AM, Sascha Hauer wrote:
> 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")
> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Reviewed-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
Thanks for debugging!
Ahmad
> ---
> fs/fs.c | 10 ++++++----
> 1 file changed, 6 insertions(+), 4 deletions(-)
>
> diff --git a/fs/fs.c b/fs/fs.c
> index 528299e039..d884726187 100644
> --- a/fs/fs.c
> +++ b/fs/fs.c
> @@ -2680,7 +2680,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;
> }
>
> @@ -2710,9 +2715,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);
--
Pengutronix e.K. | |
Steuerwalder Str. 21 | http://www.pengutronix.de/ |
31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
prev parent reply other threads:[~2025-12-02 9:38 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-12-02 9:22 Sascha Hauer
2025-12-02 9:37 ` Ahmad Fatoum [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=a990caa7-38d0-4ff6-9d2c-58f8dde494bd@pengutronix.de \
--to=a.fatoum@pengutronix.de \
--cc=barebox@lists.infradead.org \
--cc=s.hauer@pengutronix.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox