From 2f68778f08471fb7f13a8634ebb48c6db13c0f69 Mon Sep 17 00:00:00 2001 From: Sebastian Huber Date: Mon, 16 Dec 2013 13:44:13 +0100 Subject: 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. --- cpukit/libfs/src/defaults/default_readv.c | 60 +++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 cpukit/libfs/src/defaults/default_readv.c (limited to 'cpukit/libfs/src/defaults/default_readv.c') 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 + * + * + * 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 + +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; +} -- cgit v1.2.3