jingfei195887 opened a new pull request, #21780:
URL: https://github.com/apache/nuttx/pull/21780
## Summary
unionfs has no link operations, so `symlink()`, `link()`, `readlink()` and
`lstat()` on a union mount fail with `ENOSYS`, even when the underlying file
systems support them.
- **fs/unionfs: add link, symlink, readlink and lstat.** Forward them to the
underlying file systems: `symlink` goes to the first one that accepts it,
`link` stays on the file system that holds the source and returns `EXDEV`
when the destination is outside it, `readlink` falls through to the second
file system only on `ENOENT`, and `lstat` does not follow the final link.
## Impact
unionfs with `CONFIG_FS_LINKS` only; without it nothing changes.
## Testing
Host: Ubuntu x86_64, gcc (Ubuntu 13.1.0-8ubuntu1~22.04) 13.1.0, master
c7887b8bb2, `sim:nsh` with
`CONFIG_FS_UNIONFS`, `CONFIG_FS_HOSTFS`, `CONFIG_FS_TMPFS` and
`CONFIG_FS_LINKS`. The union `/u` joins a tmpfs (`/ut`) and a hostfs
(`/uh`) whose host directory holds `base.txt` and `ulnk -> base.txt`:
| command | master | this PR |
|---|---|---|
| `readlink /u/ulnk` | ENOSYS | `base.txt` |
| `ln -s base.txt /u/newlnk`, then `readlink` | ENOSYS | `base.txt` |
| `ln /u/base.txt /u/hard.txt`, then `cat` | ENOSYS | file content |
On the host, `newlnk` is a symlink to `base.txt` and `hard.txt` shares the
inode of `base.txt` (link count 2). `cat /u/ulnk` works on both, since open
already follows the link in the underlying hostfs.
- `./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]