fs: add hardlink and mountpt link/lstat infrastructure - #19949
Open
Kaben123 wants to merge 5 commits into
Open
Conversation
Kaben123
requested review from
Donny9,
GUIDINGLI,
acassis,
anchao,
btashton,
hartmannathan,
jerpelea,
lupyuen,
masayuki2009,
michallenc,
pkarashchenko,
pussuw,
raiden00pl,
tmedicci,
xiaoxiang781216 and
yamt
as code owners
August 24, 2026 11:39
|
Contributor
|
@Kaben123 fix: |
Kaben123
force-pushed
the
pse52-01-link-infra
branch
2 times, most recently
from
August 25, 2026 02:36
3f2a431 to
0666a5e
Compare
xiaoxiang781216
previously approved these changes
Aug 25, 2026
1. add the hardlink function 2. _POSIX_LINK_MAX judgement Signed-off-by: zhengyu16 <zhengyu16@xiaomi.com>
Kaben123
force-pushed
the
pse52-01-link-infra
branch
from
August 25, 2026 06:57
0666a5e to
42498d5
Compare
xiaoxiang781216
previously approved these changes
Aug 25, 2026
The link support is no longer limited to the pseudo file system and now covers both soft (symbolic) links and hard links across the VFS. Rename the configuration option PSEUDOFS_SOFTLINKS to the more accurate FS_LINKS and update all references in the source, headers, Kconfig, documentation and board defconfigs accordingly. This is a configuration rename; any out-of-tree defconfig that still selects PSEUDOFS_SOFTLINKS must be updated to FS_LINKS. Signed-off-by: zhengyu16 <zhengyu16@xiaomi.com>
Kaben123
force-pushed
the
pse52-01-link-infra
branch
from
August 25, 2026 13:26
42498d5 to
f66e6b1
Compare
1. add three func to mountpt_operations: link symlink readlink 2. modify fs_link、fs_symlink、fs_readlink for mountpt Signed-off-by: zhengyu16 <zhengyu16@xiaomi.com>
resolve rename{7}:
On a call to rename(old, new), when the old argument points to the pathname of a directory, if the directory named by the new argument exists and is empty it shall be removed and old renamed to new.
resolve rename{23}:
EEXIST or ENOTEMPTY in errno and a return value of -1 on a call to rename(old, new) when the link named by new is a directory containing
entries other than dot and dot-dot. The named files are not changed.
Signed-off-by: zhengyu16 <zhengyu16@xiaomi.com>
Add an lstat method to mountpt_operations so that mounted file systems can report link metadata without dereferencing symbolic links. In mountptrename() and stat_recursive(), prefer lstat() over stat() when it is available so that rename() and the non-following stat path operate on the link itself rather than its target, matching POSIX semantics. Signed-off-by: zhengyu16 <zhengyu16@xiaomi.com>
Kaben123
force-pushed
the
pse52-01-link-infra
branch
from
August 25, 2026 13:33
f66e6b1 to
fa3a4a9
Compare
🔗 Cross-repo PR dependenciesThe read-only Build run reported the following dependent PR(s) and fetched head SHA(s): CI run: https://github.com/apache/nuttx/actions/runs/32854101565 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR adds the core hardlink and mountpoint link infrastructure to the
NuttX filesystem layer. It is the foundation of a larger PSE52/POSIX
filesystem-enhancement stack (path resolution, FS backends, and bug fixes
will follow in separate PRs).
Changes (one upstream commit each):
link()now creates areal hard link within the pseudo-filesystem (instead of silently
degrading to a symlink). A hard-link inode type (
FSNODEFLAG_TYPE_HARDLINK)is added, and the target link count is tracked in the high bits of
i_crefs(INODE_NLINK_INC), enforcing_POSIX_LINK_MAX.soft and hard links, so the option is renamed. All references
(syscall.csv, syscall_lookup.h, lib_realpath, link/at wrappers, board
defconfigs) are updated accordingly.
link,symlink,readlinkmethods tomountpt_operationsso mountedfilesystems can implement links; the VFS wrappers are updated to route to
them.
POSIX rename semantics for directories (empty target dir is removed;
non-empty yields
ENOTEMPTY).lstatsorename does not dereference symbolic links.
Impact
CONFIG_PSEUDOFS_SOFTLINKSis renamed toCONFIG_FS_LINKS. Out-of-tree configs referencing the old name must beupdated. In-tree defconfigs are migrated in this PR.
mountpt_operationsmethods (link/symlink/readlink/lstat) areappended at the end of the struct (guarded by
CONFIG_FS_LINKS), soexisting filesystems' positional initializers are unaffected.
link()behavior changes for pseudofs: it now creates a true hard linkrather than a symlink.
Testing
sim:nshwithCONFIG_FS_LINKSenabled — zero errors/warnings.tools/checkpatch.shpasses on all changed lines.This is part of a filesystem enhancement stack. Follow-up PRs:
Depends-On: apache/nuttx-apps#3753