summaryrefslogtreecommitdiff
path: root/nuttx/fs/aio/aioc_contain.c
diff options
context:
space:
mode:
authorGregory Nutt <gnutt@nuttx.org>2014-10-06 10:53:25 -0600
committerGregory Nutt <gnutt@nuttx.org>2014-10-06 10:53:25 -0600
commitd35fa6bacd380d6adc2f836c145d2d38ea8e4f58 (patch)
treebc664dc5d35c6ffdff374cffcdc3ecba957b561e /nuttx/fs/aio/aioc_contain.c
parentdb2913ffe4b278b362a631963f24381d067517a9 (diff)
downloadpx4-nuttx-d35fa6bacd380d6adc2f836c145d2d38ea8e4f58.tar.gz
px4-nuttx-d35fa6bacd380d6adc2f836c145d2d38ea8e4f58.tar.bz2
px4-nuttx-d35fa6bacd380d6adc2f836c145d2d38ea8e4f58.zip
Major structure of file system functions to better support asynchronous I/O. Respository should not be trusted until I have a chance to verify everything
Diffstat (limited to 'nuttx/fs/aio/aioc_contain.c')
-rw-r--r--nuttx/fs/aio/aioc_contain.c17
1 files changed, 16 insertions, 1 deletions
diff --git a/nuttx/fs/aio/aioc_contain.c b/nuttx/fs/aio/aioc_contain.c
index e608a8659..34842bd21 100644
--- a/nuttx/fs/aio/aioc_contain.c
+++ b/nuttx/fs/aio/aioc_contain.c
@@ -41,6 +41,8 @@
#include <sched.h>
+#include <nuttx/fs.h>
+
#include "aio/aio.h"
#ifdef CONFIG_FS_AIO
@@ -80,15 +82,27 @@
* Returned Value:
* A reference to the new AIO control block container. This function
* will not fail but will wait if necessary for the resources to perform
- * this operation.
+ * this operation. NULL will be returned on certain errors with the
+ * errno value already set appropriately.
*
****************************************************************************/
FAR struct aio_container_s *aio_contain(FAR struct aiocb *aiocbp)
{
FAR struct aio_container_s *aioc;
+ FAR struct file *filep;
struct sched_param param;
+ /* Get the file structure corresponding to the file descriptor. */
+
+ filep = fs_getfilep(aiocbp->aio_fildes);
+ if (!filep)
+ {
+ /* The errno value has already been set */
+
+ return NULL;
+ }
+
/* Allocate the AIO control block container, waiting for one to become
* available if necessary. This should never fail.
*/
@@ -100,6 +114,7 @@ FAR struct aio_container_s *aio_contain(FAR struct aiocb *aiocbp)
memset(aioc, 0, sizeof(struct aio_container_s));
aioc->aioc_aiocbp = aiocbp;
+ aioc->aioc_filep = filep;
aioc->aioc_pid = getpid();
DEBUGVERIFY(sched_getparam (aioc->aioc_pid, &param));