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:
yukangzhi
2025-05-28 10:49:02 +08:00
committed by Xiang Xiao
parent b7fd8a268d
commit b50c5f6638
+12
View File
@@ -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;
}