jingfei195887 opened a new pull request, #21779:
URL: https://github.com/apache/nuttx/pull/21779
## Summary
NFS has no symbolic link support: a path through a symlink on the server
fails, and `symlink()`, `link()`, `readlink()` and `lstat()` on an NFS
mount are not implemented.
- **fs/nfs: follow symbolic links in path lookup.** `nfs_findnode()` and
`nfs_finddir()` read the link target with READLINK and resolve it relative
to the directory that holds the link, up to `SYMLOOP_MAX` levels. Callers
can ask not to follow the final component.
- **fs/nfs: add link, symlink, readlink and lstat.** Implemented with the
NFSv3 SYMLINK, LINK and READLINK procedures; `lstat()` returns the
attributes of the link itself. The new NFSv3 structure names are added to
the nxstyle whitelist next to the existing ones.
## Impact
NFS only, and the link operations only with `CONFIG_FS_LINKS`. Link targets
are resolved inside the mount: an absolute target returns `ENOSYS`.
## Testing
Host: Ubuntu x86_64, gcc (Ubuntu 13.1.0-8ubuntu1~22.04) 13.1.0, master
dc9481383e, `sim:nsh` with `CONFIG_NET`,
`CONFIG_NET_TCP`, `CONFIG_NET_UDP`, `CONFIG_NET_SOCKOPTS`, `CONFIG_NFS`,
`CONFIG_FS_LINKS` and a TAP device on a host bridge. The host runs the Linux
kernel NFS server (NFSv3 over TCP); the export holds `top.txt`,
`sub/file.txt`, `dlnk -> sub` and `flnk -> top.txt`. NSH commands:
| command | master | this PR |
|---|---|---|
| `cat /nfs/dlnk/file.txt` | open fails, ENOTDIR | prints the file |
| `readlink /nfs/flnk` | ENOSYS | `top.txt` |
| `ln -s top.txt /nfs/newlnk`, then `readlink` and `cat` | ENOSYS |
`top.txt`, file content |
| `ln /nfs/top.txt /nfs/hard.txt`, then `cat` | ENOSYS | file content |
On the host, `newlnk` is a symlink to `top.txt` and `hard.txt` shares the
inode of `top.txt` (link count 2).
- Each commit builds on its own.
- `./tools/checkpatch.sh -g master..HEAD`: all checks pass.
- Make and CMake builds pass with no new warnings; `ostest` exits with
status 0.
--
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]