jingfei195887 opened a new pull request, #21664: URL: https://github.com/apache/nuttx/pull/21664
## Summary `hostfs_bind()` returns OK without checking the host path, so mounting a host directory that does not exist succeeds and occupies the mountpoint. Every later access through that mountpoint then fails. Call `host_stat()` on the resolved root and fail the mount if it reports an error. ## Impact Mounting a missing host directory now fails with the error from `host_stat()` (ENOENT on sim). Mounting an existing directory is unchanged. On the semihosting backends (arm, arm64, risc-v, xtensa) `host_stat()` reports a directory when the path cannot be opened, so the mount behaves as before there. ## Testing Host: Ubuntu x86_64, gcc (Ubuntu 13.1.0-8ubuntu1~22.04) 13.1.0, master 03aea78639, `sim:nsh`. ``` nsh> mount -t hostfs -o fs=/tmp/missing /h1 master: (no error, mount succeeds) this PR: nsh: mount: mount failed: 2 nsh> mount -t hostfs -o fs=/tmp/existing /h2 nsh> cat /h2/hello.txt hello-hostfs (both) ``` - `./tools/checkpatch.sh -g master..HEAD`: all checks pass. - Make and CMake builds of `sim:nsh` pass; `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]
