This is an automated email from the ASF dual-hosted git repository.
xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git
The following commit(s) were added to refs/heads/master by this push:
new b50c5f66383 note/noteram: add FIONREAD ioctl to report unread buffer
size
b50c5f66383 is described below
commit b50c5f66383153d0ea72e1ab76a99341591a5046
Author: yukangzhi <[email protected]>
AuthorDate: Wed May 28 10:49:02 2025 +0800
note/noteram: add FIONREAD ioctl to report unread buffer size
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.
Signed-off-by: yukangzhi <[email protected]>
---
drivers/note/noteram_driver.c | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/drivers/note/noteram_driver.c b/drivers/note/noteram_driver.c
index 0cca512e41e..d19a4cb454c 100644
--- a/drivers/note/noteram_driver.c
+++ b/drivers/note/noteram_driver.c
@@ -604,6 +604,18 @@ static int noteram_ioctl(FAR struct file *filep, int cmd,
unsigned long arg)
}
break;
+ case FIONREAD:
+ if (arg == 0)
+ {
+ ret = -EINVAL;
+ }
+ else
+ {
+ *(FAR unsigned int *)arg = noteram_unread_length(drv);
+ ret = OK;
+ }
+ break;
+
default:
break;
}