From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: barebox@lists.infradead.org
Cc: Ahmad Fatoum <a.fatoum@pengutronix.de>,
"Claude Opus 4.6" <noreply@anthropic.com>
Subject: [PATCH 5/5] fs: fix relative path resolution when CWD is on a TFTP mount
Date: Thu, 12 Mar 2026 15:44:25 +0100 [thread overview]
Message-ID: <20260312144428.2158727-5-a.fatoum@pengutronix.de> (raw)
In-Reply-To: <20260312144428.2158727-1-a.fatoum@pengutronix.de>
When the current working directory is on a TFTP mount, relative paths
containing subdirectories (e.g. 'subdir/file') fail because
link_path_walk() tries to look up the first component as a directory,
which TFTP does not support.
The in-loop dentry_is_tftp() check already handles separator switching
for absolute paths and './'-prefixed relative paths, but misses the
case where the starting dentry itself is a TFTP dentry.
Check for a TFTP dentry before entering the walk loop and switch the
separator to 0x1 upfront, so the entire relative path is collapsed
into a single TFTP filename.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
fs/fs.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/fs/fs.c b/fs/fs.c
index 6a73a5baa26e..0a151607dd7d 100644
--- a/fs/fs.c
+++ b/fs/fs.c
@@ -2140,6 +2140,14 @@ static int link_path_walk(const char *name, struct nameidata *nd)
if (!*name)
return 0;
+ /*
+ * If we are starting from a TFTP dentry (e.g. CWD is on a TFTP
+ * mount), switch to the TFTP separator immediately so the first
+ * component isn't mistakenly looked up as a directory.
+ */
+ if (dentry_is_tftp(nd->path.dentry))
+ separator = 0x1;
+
/* At this point we know we have a real path component. */
for(;;) {
int len;
--
2.47.3
next prev parent reply other threads:[~2026-03-12 14:45 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-12 14:44 [PATCH 1/5] tftp: skip memory allocation when seeking to current position Ahmad Fatoum
2026-03-12 14:44 ` [PATCH 2/5] tftp: warn when seek-heavy access wastes network bandwidth Ahmad Fatoum
2026-03-12 14:44 ` [PATCH 3/5] tftp: emulate backwards seek by reopening the file Ahmad Fatoum
2026-03-12 14:44 ` [PATCH 4/5] libfile: drop TFTP-specific hack in open_fdt() Ahmad Fatoum
2026-03-12 14:44 ` Ahmad Fatoum [this message]
2026-03-17 10:21 ` [PATCH 1/5] tftp: skip memory allocation when seeking to current position Sascha Hauer
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=20260312144428.2158727-5-a.fatoum@pengutronix.de \
--to=a.fatoum@pengutronix.de \
--cc=barebox@lists.infradead.org \
--cc=noreply@anthropic.com \
/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