mirror of
https://github.com/apache/nuttx.git
synced 2026-05-23 14:58:13 +08:00
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 <yukangzhi@xiaomi.com>
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user