libs/libc/aio: fix aio_write compatible bug
1. make the aio_write implementation can pass the lpt/open_posix_testsuite/aio_write testcases 2. the modification are referred to https://pubs.opengroup.org/onlinepubs/9699919799/functions/aio_write.html Signed-off-by: guoshichao <guoshichao@xiaomi.com>
This commit is contained in:
parent
7d13f5eb78
commit
dc69b108b8
|
@ -249,6 +249,40 @@ int aio_write(FAR struct aiocb *aiocbp)
|
|||
|
||||
DEBUGASSERT(aiocbp);
|
||||
|
||||
if (aiocbp->aio_reqprio < 0)
|
||||
{
|
||||
set_errno(EINVAL);
|
||||
return ERROR;
|
||||
}
|
||||
|
||||
if (aiocbp->aio_offset < 0)
|
||||
{
|
||||
aiocbp->aio_result = -EINVAL;
|
||||
return OK;
|
||||
}
|
||||
|
||||
if (aiocbp->aio_fildes < 0)
|
||||
{
|
||||
/* for EBADF, the aio_write do not return error directly, but using
|
||||
* aio_error to return this error code
|
||||
*/
|
||||
|
||||
aiocbp->aio_result = -EBADF;
|
||||
return OK;
|
||||
}
|
||||
|
||||
/* the aio_fildes that transferred in may be opened with O_RDONLY, for this
|
||||
* case, we need to return OK directly, and using the aio_error to collect
|
||||
* the EBADF error code
|
||||
*/
|
||||
|
||||
int flags = fcntl(aiocbp->aio_fildes, F_GETFL);
|
||||
if (!(flags & O_WRONLY))
|
||||
{
|
||||
aiocbp->aio_result = -EBADF;
|
||||
return OK;
|
||||
}
|
||||
|
||||
/* The result -EINPROGRESS means that the transfer has not yet completed */
|
||||
|
||||
sigwork_init(&aiocbp->aio_sigwork);
|
||||
|
|
Loading…
Reference in New Issue