mirror of
https://github.com/apache/nuttx.git
synced 2026-08-01 20:28:58 +00:00
libs/libc/aio: fix aio_read compatible bug
1. make the aio_read implementation can pass the ltp/open_posix_testsuite/aio_read testcases 2. the modification are referred to https://pubs.opengroup.org/onlinepubs/9699919799/functions/aio_read.html Signed-off-by: guoshichao <guoshichao@xiaomi.com>
This commit is contained in:
parent
f48a92810b
commit
d33f90b78c
1 changed files with 28 additions and 0 deletions
|
|
@ -219,6 +219,34 @@ int aio_read(FAR struct aiocb *aiocbp)
|
|||
|
||||
DEBUGASSERT(aiocbp);
|
||||
|
||||
if (aiocbp->aio_reqprio < 0)
|
||||
{
|
||||
set_errno(EINVAL);
|
||||
return ERROR;
|
||||
}
|
||||
|
||||
if (aiocbp->aio_fildes < 0)
|
||||
{
|
||||
/* the EBADF should be collected by aio_error(), we need return OK at
|
||||
* here
|
||||
*/
|
||||
|
||||
aiocbp->aio_result = -EBADF;
|
||||
return OK;
|
||||
}
|
||||
|
||||
/* for aio_read, the aio_offset should be large or equal than 0 */
|
||||
|
||||
if (aiocbp->aio_offset < 0)
|
||||
{
|
||||
/* the EINVAL should be collected by aio_error(), we need to return OK
|
||||
* here
|
||||
*/
|
||||
|
||||
aiocbp->aio_result = -EINVAL;
|
||||
return OK;
|
||||
}
|
||||
|
||||
/* The result -EINPROGRESS means that the transfer has not yet completed */
|
||||
|
||||
sigwork_init(&aiocbp->aio_sigwork);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue