jingfei195887 opened a new pull request, #21949:
URL: https://github.com/apache/nuttx/pull/21949
## Summary
- **fs/hostfs: Implement syncfs operation.**
The `syncfs` slot of `g_hostfs_operations` was NULL, so `syncfs()` on a
file in a hostfs mount always failed: `file_syncfs()` finds no `syncfs`
method and returns `-EBADF`. Add `hostfs_syncfs()`, which walks the open
files of the mount under `fs_lock` and calls `host_sync()` on each host
descriptor, the same call `hostfs_sync()` already makes for one file.
## Impact
- New feature / API change: NO new API; `syncfs()` now works on hostfs.
- Behavior: `syncfs()` on a hostfs file returns 0 instead of -1/`EBADF`.
- Build, hardware, documentation, security, compatibility: NO.
## Testing
Host: Ubuntu x86_64, gcc (Ubuntu 13.1.0-8ubuntu1~22.04) 13.1.0.
`sim:nsh` (hostfs enabled by default): mount a host directory, open a file,
write to it and call `syncfs()` on the descriptor:
```
mount -t hostfs -o fs=/tmp/fsup_hostfs_ok /h
fsuptest syncfs /h/syncfs.txt
```
Testing logs before change (master fb41e5e8cb):
```
syncfs: ret=-1 errno=9
```
Testing logs after change:
```
syncfs: ret=0 errno=0
```
The branch was then rebased onto master e9eefaa0e9 (no conflicts, patch
unchanged) and the build checks below were rerun there.
- `./tools/checkpatch.sh -g master..HEAD`: all checks pass.
- `sim:nsh` Make and CMake builds pass with no new warnings in the changed
file; `ostest` exits with status 0.
- Verified on sim only.
## PR verification Self-Check
* [x] This PR introduces only one functional change.
* [x] I have updated all required description fields above.
* [x] My PR adheres to Contributing Guidelines and Documentation (git commit
title and message, coding standard, etc).
* [ ] My PR is still work in progress (not ready for review).
* [x] My PR is ready for review and can be safely merged into a codebase.
--
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]