casaroli opened a new pull request, #20797: URL: https://github.com/apache/nuttx/pull/20797
## Summary `rename()` on hostfs did nothing and returned 0. Commit 86193c95caee changed the two path buffers of `hostfs_rename()` from arrays to pointers, but kept `sizeof()` as the buffer size. `sizeof()` of a pointer is 4 or 8, so `strlcpy()` kept only the first 3 or 7 characters of the host root directory, and both host paths became the same string. The host `rename()` of a path to itself succeeds and changes nothing. `hostfs_rename()` now makes both paths with `hostfs_mkpath()` and `HOSTFS_MAX_PATH`, as the other hostfs functions do. ## Impact `rename()` and `mv` work again on hostfs. No new configuration option, no documentation change. ## Testing `sim:nsh` (Linux arm64 host, in Docker), hostfs mounted on an empty host directory, NSH commands `echo A > /host/hf_a`, `mv /host/hf_a /host/hf_b`, `ls`, `cat`, then a second `mv` over the existing `hf_b`: | | master | this PR | |---|---|---| | `mv` to a new name | no error, `hf_a` stays, `cat /host/hf_b`: `open failed: 2` | `hf_b` holds `A`, `hf_a` is gone | | `mv` over an existing file | no error, nothing changes | `hf_b` holds `B` | | host directory after the run | `hf_a` (B) | `hf_b` (B) | `qemu-armv8a:knsh` (semihosting hostfs, TCG) builds and ostest passes; rename on semihosting hostfs cannot be tested there, because semihosting `host_stat()` reports every missing path as a directory, so the VFS returns `EISDIR` first (also on master). `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]
