jingfei195887 opened a new pull request, #22174:
URL: https://github.com/apache/nuttx/pull/22174

   ## Summary
   
   Forward inotify watches across rpmsgfs, so a watch on an rpmsgfs mount
   reports changes made on the server core. Builds on the file system notify
   callback added in #22116.
   
   - **fs/vfs: Add in-kernel inotify watch callback API.**
     `file_notify_open()`, `file_notify_add_watch()`, `file_notify_rm_watch()`
     and `file_notify_close()` operate on a caller-provided `struct file`.
     Instead of queueing events for a reader, the instance delivers each event
     to a callback in the context that generated it, so an in-kernel consumer
     can watch paths without an inotify descriptor and a polling thread.
     `inotify_add_watch()` / `inotify_rm_watch()` become thin wrappers.
   - **fs/rpmsgfs: Forward inotify watches and remote events.**
     New `RPMSGFS_WATCH` (ADD answers with the server watch descriptor, RM
     carries it back and is not answered) and `RPMSGFS_NOTIFY` (server to
     client, unsolicited). The server keeps one in-kernel inotify instance per
     client; the client maps descriptors back to mountpoint paths and injects
     the events with `notify_event()` from the low priority work queue, since
     the rpmsg rx context must not block on the inotify locks. Gated by
     `CONFIG_FS_RPMSGFS_SERVER_NOTIFY` (default y when `FS_NOTIFY` is set).
   
   Applied to current master: `struct pollfd_s`, `lib_get_pathbuffer()`,
   the `CONFIG_FS_NOTIFY_INJECT` `O_RDWR` case in `inotify_init1()`, and the
   documentation in `Documentation/os/filesystem/rpmsgfs.rst`.
   
   ## Impact
   
   - New feature / API change: YES. New fs-internal `file_notify_*()` API in
     `include/nuttx/fs/fs.h`; two new rpmsgfs commands appended after the
     existing ones. A server built without `FS_RPMSGFS_SERVER_NOTIFY` rejects
     `RPMSGFS_WATCH` and the client keeps local-only behavior.
   - Behavior: `inotify_add_watch()` on an rpmsgfs path now also reports
     changes made on the server. Local watches are unchanged.
   - Build, hardware, documentation (updated), security, compatibility: see
     above.
   
   ## Testing
   
   Host: Ubuntu 22.04 x86_64, gcc 13.1.0. Base: master 960459c650.
   
   `sim:rpserver` + `sim:rpproxy`, both with `CONFIG_FS_NOTIFY` and
   `CONFIG_FS_LINKS`. The server mounts a tmpfs at `/tlk`, creates `/tlk/f`
   and appends to it about 9 s later. The proxy mounts the server's `/tlk`
   with rpmsgfs, adds an inotify watch on `/rh/f` and reads events for 10 s.
   
   Testing logs before change:
   
   ```
   rpwatch: add_watch /rh/f wd=1 errno=0
   rpwatch: events=0
   ```
   
   Testing logs after change (`IN_MODIFY`, then `IN_CLOSE_WRITE`):
   
   ```
   rpwatch: add_watch /rh/f wd=1 errno=0
   rpwatch: event wd=1 mask=0x00000002
   rpwatch: event wd=1 mask=0x00000008
   rpwatch: events=2
   ```
   
   - `./tools/checkpatch.sh -g master..HEAD`: all checks pass.
   - `sim:nsh` with `CONFIG_RPTUN`, `CONFIG_FS_RPMSGFS`,
     `CONFIG_FS_RPMSGFS_SERVER`, `CONFIG_FS_NOTIFY`: Make and CMake builds
     pass with no warnings in the changed files; `ostest` exits with status 0.
   - Each commit builds on its own with `CONFIG_FS_NOTIFY` on and off.
   - 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]

Reply via email to