casaroli opened a new pull request, #20800:
URL: https://github.com/apache/nuttx/pull/20800
## Summary
`rename()` of a directory to a path below itself must fail with `EINVAL`.
NuttX did not always check this:
- `mountptrename()` checked it only when the new path already existed. When
it did not exist, the request went to the file system, and tmpfs moved the
directory into itself.
- `pseudorename()` did not check it, and moved a pseudo directory into
itself.
In both cases `rename("/x/a", "/x/a/sub")` returned 0 and `/x/a` could no
longer be found. `mountptrename()` now does the check for every directory,
before it looks for the new path. `pseudorename()` does it before it changes
the inode tree.
This PR is stacked on apache/nuttx#20799 (both change the same lines of
`mountptrename()`); the commits of #20799 drop out when this PR is rebased
after it merges. The relevant commit is the last one.
depends-on: apache/nuttx/pull/20799
## Impact
Only a rename of a directory into its own subtree changes: it now fails with
`EINVAL`. No new configuration option.
## Testing
`renameatomic.c` on `qemu-armv8a:knsh` under HVF: tmpfs mounted by the test,
v9fs on `/system`, pseudo directories under `/s5p`.
| `rename(a, a/sub)` | master | this PR |
|---|---|---|
| tmpfs | returns 0, `a` is gone | `EINVAL`, `a` kept |
| pseudo file system | returns 0, `a` is gone | `EINVAL`, `a` kept |
| v9fs | `EINVAL` (from the host) | `EINVAL` |
ostest passes on `qemu-armv8a:knsh` and `qemu-armv8a:nsh`.
`tools/checkpatch.sh -c -u -m -g` passes.
--
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]