[PATCH 5/5] fs: fix relative path resolution when CWD is on a TFTP mount
Ahmad Fatoum
a.fatoum at pengutronix.de
Thu Mar 12 07:44:25 PDT 2026
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 at anthropic.com>
Signed-off-by: Ahmad Fatoum <a.fatoum at 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
More information about the barebox
mailing list