From: Sascha Hauer <s.hauer@pengutronix.de>
To: BAREBOX <barebox@lists.infradead.org>
Subject: [PATCH 1/9] fs: ramfs: report symlink target length as st_size
Date: Tue, 20 Oct 2026 09:09:26 +0200 [thread overview]
Message-ID: <20261020-fs-symlink-fixes-v1-1-e7ac8c29b08a@pengutronix.de> (raw)
In-Reply-To: <20261020-fs-symlink-fixes-v1-0-e7ac8c29b08a@pengutronix.de>
Since the switch to the dentry cache, ramfs symlinks report a size of 0.
Before that, st_size was the length of the link target, as on Linux and
as all other barebox filesystems that support symlinks still do.
Besides the cosmetic issue in 'ls -l', this breaks saveenv: file_action()
allocates the readlink buffer based on st_size, so every symlink in /env
is stored in the environment truncated to its first character:
ln env/init/automount /tmp/e/foo
saveenv /tmp/e.img /tmp/e
loadenv /tmp/e.img /tmp/l
ls -l /tmp/l
l---rwx--- 0 foo -> e
Set i_size to the length of the link target again.
Fixes: b283b72639 ("fs: ramfs: Switch to dentry cache implementation")
Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
fs/ramfs.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/fs/ramfs.c b/fs/ramfs.c
index d86bf6144e..c843df6c5c 100644
--- a/fs/ramfs.c
+++ b/fs/ramfs.c
@@ -176,6 +176,7 @@ static int ramfs_symlink(struct inode *dir, struct dentry *dentry,
return -ENOSPC;
inode->i_link = xstrdup(symname);
+ inode->i_size = strlen(symname);
d_instantiate(dentry, inode);
return 0;
--
2.47.3
next prev parent reply other threads:[~2026-10-20 7:11 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-20 7:09 [PATCH 0/9] symlink fixes and improvements Sascha Hauer
2026-10-20 7:09 ` Sascha Hauer [this message]
2026-10-20 7:09 ` [PATCH 2/9] fs: qemu_fw_cfg: report symlink target length as st_size Sascha Hauer
2026-10-20 7:09 ` [PATCH 3/9] fs: ramfs: create symlinks with mode 0777 Sascha Hauer
2026-10-20 7:09 ` [PATCH 4/9] fs: follow absolute symlinks from the root directory Sascha Hauer
2026-10-20 7:09 ` [PATCH 5/9] fs: allow trailing symlinks pointing to " Sascha Hauer
2026-10-20 7:09 ` [PATCH 6/9] fs: symlink: drop references taken by filename_create() Sascha Hauer
2026-10-20 7:09 ` [PATCH 7/9] test: self: dirfd: add tests for absolute symlinks Sascha Hauer
2026-10-20 7:09 ` [PATCH 8/9] commands: ln: accept -s option Sascha Hauer
2026-10-20 7:09 ` [PATCH 9/9] commands: ln: create link inside DEST if it is a directory 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=20261020-fs-symlink-fixes-v1-1-e7ac8c29b08a@pengutronix.de \
--to=s.hauer@pengutronix.de \
--cc=barebox@lists.infradead.org \
/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