summaryrefslogtreecommitdiffstats
path: root/cpukit/libfs/src/defaults
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2013-12-16 13:44:13 +0100
committerSebastian Huber <sebastian.huber@embedded-brains.de>2013-12-20 10:31:53 +0100
commit2f68778f08471fb7f13a8634ebb48c6db13c0f69 (patch)
treeeae0deea88cc0d81052f8497a668dfaeecd6de40 /cpukit/libfs/src/defaults
parentlibcsupport: Add and use rtems_libio_iovec_eval() (diff)
downloadrtems-2f68778f08471fb7f13a8634ebb48c6db13c0f69.tar.bz2
Filesystem: Add readv/writev handlers
The readv() and writev() support was implemented in terms of multiple calls to the read and write handlers. This imposes a problem on device files which use an IO vector as single request entity. For example a low-level network device (e.g. BPF(4)) may use an IO vector to create one frame from multiple protocol layers each with its own IO vector entry.
Diffstat (limited to 'cpukit/libfs/src/defaults')
-rw-r--r--cpukit/libfs/src/defaults/default_handlers.c4
-rw-r--r--cpukit/libfs/src/defaults/default_readv.c60
-rw-r--r--cpukit/libfs/src/defaults/default_writev.c60
3 files changed, 123 insertions, 1 deletions
diff --git a/cpukit/libfs/src/defaults/default_handlers.c b/cpukit/libfs/src/defaults/default_handlers.c
index 2a10a19125..ce262b66a3 100644
--- a/cpukit/libfs/src/defaults/default_handlers.c
+++ b/cpukit/libfs/src/defaults/default_handlers.c
@@ -32,5 +32,7 @@ const rtems_filesystem_file_handlers_r rtems_filesystem_handlers_default = {
.ftruncate_h = rtems_filesystem_default_ftruncate,
.fsync_h = rtems_filesystem_default_fsync_or_fdatasync,
.fdatasync_h = rtems_filesystem_default_fsync_or_fdatasync,
- .fcntl_h = rtems_filesystem_default_fcntl
+ .fcntl_h = rtems_filesystem_default_fcntl,
+ .readv_h = rtems_filesystem_default_readv,
+ .writev_h = rtems_filesystem_default_writev
};
diff --git a/cpukit/libfs/src/defaults/default_readv.c b/cpukit/libfs/src/defaults/default_readv.c
new file mode 100644
index 0000000000..063ed5e678
--- /dev/null
+++ b/cpukit/libfs/src/defaults/default_readv.c
@@ -0,0 +1,60 @@
+/**
+ * @file
+ *
+ * @brief Default Read IO Vector Handler
+ *
+ * @ingroup LibIOFSHandler
+ */
+
+/*
+ * COPYRIGHT (c) 1989-2011.
+ * On-Line Applications Research Corporation (OAR).
+ *
+ * Copyright (c) 2013 embedded brains GmbH. All rights reserved.
+ *
+ * embedded brains GmbH
+ * Dornierstr. 4
+ * 82178 Puchheim
+ * Germany
+ * <rtems@embedded-brains.de>
+ *
+ * The license and distribution terms for this file may be
+ * found in the file LICENSE in this distribution or at
+ * http://www.rtems.com/license/LICENSE.
+ */
+
+#if HAVE_CONFIG_H
+ #include "config.h"
+#endif
+
+#include <rtems/libio_.h>
+
+ssize_t rtems_filesystem_default_readv(
+ rtems_libio_t *iop,
+ const struct iovec *iov,
+ int iovcnt,
+ ssize_t total
+)
+{
+ int v;
+
+ total = 0;
+
+ for ( v = 0 ; v < iovcnt ; ++v ) {
+ ssize_t bytes = ( *iop->pathinfo.handlers->read_h )(
+ iop,
+ iov[ v ].iov_base,
+ iov[ v ].iov_len
+ );
+
+ if ( bytes < 0 )
+ return -1;
+
+ total += bytes;
+
+ if ( bytes != iov[ v ].iov_len )
+ break;
+ }
+
+ return total;
+}
diff --git a/cpukit/libfs/src/defaults/default_writev.c b/cpukit/libfs/src/defaults/default_writev.c
new file mode 100644
index 0000000000..e62e084e72
--- /dev/null
+++ b/cpukit/libfs/src/defaults/default_writev.c
@@ -0,0 +1,60 @@
+/**
+ * @file
+ *
+ * @brief Default Read IO Vector Handler
+ *
+ * @ingroup LibIOFSHandler
+ */
+
+/*
+ * COPYRIGHT (c) 1989-2011.
+ * On-Line Applications Research Corporation (OAR).
+ *
+ * Copyright (c) 2013 embedded brains GmbH. All rights reserved.
+ *
+ * embedded brains GmbH
+ * Dornierstr. 4
+ * 82178 Puchheim
+ * Germany
+ * <rtems@embedded-brains.de>
+ *
+ * The license and distribution terms for this file may be
+ * found in the file LICENSE in this distribution or at
+ * http://www.rtems.com/license/LICENSE.
+ */
+
+#if HAVE_CONFIG_H
+ #include "config.h"
+#endif
+
+#include <rtems/libio_.h>
+
+ssize_t rtems_filesystem_default_writev(
+ rtems_libio_t *iop,
+ const struct iovec *iov,
+ int iovcnt,
+ ssize_t total
+)
+{
+ int v;
+
+ total = 0;
+
+ for ( v = 0 ; v < iovcnt ; ++v ) {
+ ssize_t bytes = ( *iop->pathinfo.handlers->write_h )(
+ iop,
+ iov[ v ].iov_base,
+ iov[ v ].iov_len
+ );
+
+ if ( bytes < 0 )
+ return -1;
+
+ total += bytes;
+
+ if ( bytes != iov[ v ].iov_len )
+ break;
+ }
+
+ return total;
+}