diff options
author | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2013-12-16 13:44:13 +0100 |
---|---|---|
committer | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2013-12-20 10:31:53 +0100 |
commit | 2f68778f08471fb7f13a8634ebb48c6db13c0f69 (patch) | |
tree | eae0deea88cc0d81052f8497a668dfaeecd6de40 /cpukit/libcsupport/src | |
parent | libcsupport: Add and use rtems_libio_iovec_eval() (diff) | |
download | rtems-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/libcsupport/src')
-rw-r--r-- | cpukit/libcsupport/src/__usrenv.c | 4 | ||||
-rw-r--r-- | cpukit/libcsupport/src/readv.c | 21 | ||||
-rw-r--r-- | cpukit/libcsupport/src/writev.c | 21 |
3 files changed, 5 insertions, 41 deletions
diff --git a/cpukit/libcsupport/src/__usrenv.c b/cpukit/libcsupport/src/__usrenv.c index 88058c4714..f8604479a5 100644 --- a/cpukit/libcsupport/src/__usrenv.c +++ b/cpukit/libcsupport/src/__usrenv.c @@ -54,7 +54,9 @@ const rtems_filesystem_file_handlers_r rtems_filesystem_null_handlers = { .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 }; static void null_op_lock_or_unlock( diff --git a/cpukit/libcsupport/src/readv.c b/cpukit/libcsupport/src/readv.c index e47f22850a..6a4e0579f3 100644 --- a/cpukit/libcsupport/src/readv.c +++ b/cpukit/libcsupport/src/readv.c @@ -36,31 +36,12 @@ ssize_t readv( ) { ssize_t total; - int v; rtems_libio_t *iop; total = rtems_libio_iovec_eval( fd, iov, iovcnt, LIBIO_FLAGS_READ, &iop ); if ( total > 0 ) { - /* - * Now process the readv(). - */ - 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; - } + total = ( *iop->pathinfo.handlers->readv_h )( iop, iov, iovcnt, total ); } return total; diff --git a/cpukit/libcsupport/src/writev.c b/cpukit/libcsupport/src/writev.c index 4a8dc735b8..7fa55bdbe5 100644 --- a/cpukit/libcsupport/src/writev.c +++ b/cpukit/libcsupport/src/writev.c @@ -28,31 +28,12 @@ ssize_t writev( ) { ssize_t total; - int v; rtems_libio_t *iop; total = rtems_libio_iovec_eval( fd, iov, iovcnt, LIBIO_FLAGS_WRITE, &iop ); if ( total > 0 ) { - /* - * Now process the writev(). - */ - 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; - } + total = ( *iop->pathinfo.handlers->writev_h )( iop, iov, iovcnt, total ); } return total; |