Kaben123 opened a new pull request, #18115: URL: https://github.com/apache/nuttx/pull/18115
Add handling for the FIONREAD ioctl in noteram_ioctl to return the number of unread bytes in the circular note buffer (noteram_unread_length()). Validate the argument pointer and return -EINVAL if it is NULL. *Note: Please adhere to [Contributing Guidelines](https://github.com/apache/nuttx/blob/master/CONTRIBUTING.md).* ## Summary This patch adds support for the FIONREAD ioctl command in the noteram driver to allow user-space to query the number of unread bytes in the circular note buffer. ## Motivation User-space consumers of /dev/note/ram can benefit from being able to query the available unread size for efficient reads without blocking or to size buffers appropriately. ## What was changed - `drivers/note/noteram_driver.c` - Added handling for `FIONREAD` in `noteram_ioctl()` to return the result of `noteram_unread_length()` when a valid pointer is passed. ## Impact - Functional behavior: Adds a new ioctl handler; no behavior change to existing functionality. - API/ABI: Adds support for a commonly used ioctl (FIONREAD) on the device node. - Risks: Minimal. The added code verifies `arg` and returns -EINVAL for null pointer. ## Testing - Compiled and ran on development board. Verified `ioctl(fd, FIONREAD, &size)` returns expected available bytes. -- 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]
