jingfei195887 opened a new pull request, #21684:
URL: https://github.com/apache/nuttx/pull/21684
## Summary
`romfs_opendir()` does not count the open directory in `rm_refs`, so
`romfs_unbind()` lets the volume be unmounted while a directory handle
is still open. The later `closedir()` then works on a mount that is
gone. Take a reference in `romfs_opendir()` and drop it in
`romfs_closedir()`, the same way open files are counted.
The second commit fixes the nxstyle errors that were already in
`fs_romfs.c`, so the file passes `checkpatch.sh`. It does not change
behavior.
## Impact
`umount()` of a ROMFS volume with an open directory now fails with
EBUSY, as it already does with an open file. It succeeds after the
directory is closed.
## Testing
Host: Ubuntu x86_64, gcc (Ubuntu 13.1.0-8ubuntu1~22.04) 13.1.0, master
03aea78639, `sim:nsh` (`/etc` is a
ROMFS mount). A small test program opens `/etc` with `opendir()`,
reads one entry, calls `umount("/etc")`, then `closedir()`, then
`umount("/etc")` again:
| step | master | this PR |
|---|---|---|
| `umount` with the directory open | 0 (unmounted) | -1, EBUSY |
| `closedir` | `Assertion failed inode->i_peer == NULL` in `inode_release()`
| OK |
| `umount` after `closedir` | not reached | 0 |
- `./tools/checkpatch.sh -g master..HEAD`: all checks pass.
- Make and CMake builds pass (also with `CONFIG_FS_ROMFS_CACHE_NODE=y`);
`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]