Kaben123 opened a new pull request, #19949:
URL: https://github.com/apache/nuttx/pull/19949
## 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):
1. **fs/vfs: add hardlink function of pseudofs** — `link()` now creates a
real 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`.
2. **fs: rename PSEUDOFS_SOFTLINKS to FS_LINKS** — the config now covers both
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.
3. **fs/vfs: add link/symlink/readlink support for mountpt** — adds `link`,
`symlink`, `readlink` methods to `mountpt_operations` so mounted
filesystems can implement links; the VFS wrappers are updated to route to
them.
4. **fs/vfs/rename: rename a directory to an empty directory** — implements
POSIX rename semantics for directories (empty target dir is removed;
non-empty yields `ENOTEMPTY`).
5. **fs/vfs: add lstat interface to mountpt_operations** — adds `lstat` so
rename does not dereference symbolic links.
## Impact
- **Breaking config change:** `CONFIG_PSEUDOFS_SOFTLINKS` is renamed to
`CONFIG_FS_LINKS`. Out-of-tree configs referencing the old name must be
updated. In-tree defconfigs are migrated in this PR.
- New `mountpt_operations` methods (`link`/`symlink`/`readlink`/`lstat`) are
appended at the end of the struct (guarded by `CONFIG_FS_LINKS`), so
existing filesystems' positional initializers are unaffected.
- `link()` behavior changes for pseudofs: it now creates a true hard link
rather than a symlink.
## Testing
- Built `sim:nsh` with `CONFIG_FS_LINKS` enabled — zero errors/warnings.
- `tools/checkpatch.sh` passes on all changed lines.
---
This is part of a filesystem enhancement stack. Follow-up PRs:
- inode path-resolution infrastructure (independent, based on master)
- hostfs/rpmsgfs link/lstat backends (**depends on this PR**)
- target FS bug fixes (**depends on this PR + the other two**)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]