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.
This commit is contained in:
Sebastian Huber
2013-12-16 13:44:13 +01:00
parent 95a57280eb
commit 2f68778f08
28 changed files with 402 additions and 148 deletions

View File

@@ -675,5 +675,7 @@ static const rtems_filesystem_file_handlers_r rtems_tfs_handlers = {
.ftruncate_h = rtems_tfs_ftruncate, .ftruncate_h = rtems_tfs_ftruncate,
.fsync_h = rtems_filesystem_default_fsync_or_fdatasync, .fsync_h = rtems_filesystem_default_fsync_or_fdatasync,
.fdatasync_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
}; };

View File

@@ -220,7 +220,9 @@ static const rtems_filesystem_file_handlers_r rtems_blkdev_imfs_node = {
.ftruncate_h = rtems_filesystem_default_ftruncate, .ftruncate_h = rtems_filesystem_default_ftruncate,
.fsync_h = rtems_blkdev_imfs_fsync_or_fdatasync, .fsync_h = rtems_blkdev_imfs_fsync_or_fdatasync,
.fdatasync_h = rtems_blkdev_imfs_fsync_or_fdatasync, .fdatasync_h = rtems_blkdev_imfs_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 IMFS_jnode_t *rtems_blkdev_imfs_initialize( static IMFS_jnode_t *rtems_blkdev_imfs_initialize(

View File

@@ -29,6 +29,7 @@
#include <sys/stat.h> #include <sys/stat.h>
#include <sys/ioctl.h> #include <sys/ioctl.h>
#include <sys/statvfs.h> #include <sys/statvfs.h>
#include <sys/uio.h>
#include <unistd.h> #include <unistd.h>
#include <termios.h> #include <termios.h>
@@ -807,6 +808,29 @@ typedef ssize_t (*rtems_filesystem_read_t)(
size_t count size_t count
); );
/**
* @brief Reads an IO vector from a node.
*
* This handler is responsible to update the offset field of the IO descriptor.
*
* @param[in, out] iop The IO pointer.
* @param[in] iov The IO vector with buffer for read data. The caller must
* ensure that the IO vector values are valid.
* @param[in] iovcnt The count of buffers in the IO vector.
* @param[in] total The total count of bytes in the buffers in the IO vector.
*
* @retval non-negative Count of read characters.
* @retval -1 An error occurred. The errno is set to indicate the error.
*
* @see rtems_filesystem_default_readv().
*/
typedef ssize_t (*rtems_filesystem_readv_t)(
rtems_libio_t *iop,
const struct iovec *iov,
int iovcnt,
ssize_t total
);
/** /**
* @brief Writes to a node. * @brief Writes to a node.
* *
@@ -827,6 +851,29 @@ typedef ssize_t (*rtems_filesystem_write_t)(
size_t count size_t count
); );
/**
* @brief Writes an IO vector to a node.
*
* This handler is responsible to update the offset field of the IO descriptor.
*
* @param[in, out] iop The IO pointer.
* @param[in] iov The IO vector with buffer for write data. The caller must
* ensure that the IO vector values are valid.
* @param[in] iovcnt The count of buffers in the IO vector.
* @param[in] total The total count of bytes in the buffers in the IO vector.
*
* @retval non-negative Count of written characters.
* @retval -1 An error occurred. The errno is set to indicate the error.
*
* @see rtems_filesystem_default_writev().
*/
typedef ssize_t (*rtems_filesystem_writev_t)(
rtems_libio_t *iop,
const struct iovec *iov,
int iovcnt,
ssize_t total
);
/** /**
* @brief IO control of a node. * @brief IO control of a node.
* *
@@ -992,6 +1039,8 @@ struct _rtems_filesystem_file_handlers_r {
rtems_filesystem_fcntl_t fcntl_h; rtems_filesystem_fcntl_t fcntl_h;
rtems_filesystem_poll_t poll_h; rtems_filesystem_poll_t poll_h;
rtems_filesystem_kqfilter_t kqfilter_h; rtems_filesystem_kqfilter_t kqfilter_h;
rtems_filesystem_readv_t readv_h;
rtems_filesystem_writev_t writev_h;
}; };
/** /**
@@ -1032,6 +1081,18 @@ ssize_t rtems_filesystem_default_read(
size_t count size_t count
); );
/**
* @brief Calls the read handler for each IO vector entry.
*
* @see rtems_filesystem_readv_t.
*/
ssize_t rtems_filesystem_default_readv(
rtems_libio_t *iop,
const struct iovec *iov,
int iovcnt,
ssize_t total
);
/** /**
* @retval -1 Always. The errno is set to ENOTSUP. * @retval -1 Always. The errno is set to ENOTSUP.
* *
@@ -1043,6 +1104,18 @@ ssize_t rtems_filesystem_default_write(
size_t count size_t count
); );
/**
* @brief Calls the write handler for each IO vector entry.
*
* @see rtems_filesystem_write_t.
*/
ssize_t rtems_filesystem_default_writev(
rtems_libio_t *iop,
const struct iovec *iov,
int iovcnt,
ssize_t total
);
/** /**
* @retval -1 Always. The errno is set to ENOTTY. * @retval -1 Always. The errno is set to ENOTTY.
* *

View File

@@ -54,7 +54,9 @@ const rtems_filesystem_file_handlers_r rtems_filesystem_null_handlers = {
.ftruncate_h = rtems_filesystem_default_ftruncate, .ftruncate_h = rtems_filesystem_default_ftruncate,
.fsync_h = rtems_filesystem_default_fsync_or_fdatasync, .fsync_h = rtems_filesystem_default_fsync_or_fdatasync,
.fdatasync_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( static void null_op_lock_or_unlock(

View File

@@ -36,31 +36,12 @@ ssize_t readv(
) )
{ {
ssize_t total; ssize_t total;
int v;
rtems_libio_t *iop; rtems_libio_t *iop;
total = rtems_libio_iovec_eval( fd, iov, iovcnt, LIBIO_FLAGS_READ, &iop ); total = rtems_libio_iovec_eval( fd, iov, iovcnt, LIBIO_FLAGS_READ, &iop );
if ( total > 0 ) { if ( total > 0 ) {
/* total = ( *iop->pathinfo.handlers->readv_h )( iop, iov, iovcnt, total );
* 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;
}
} }
return total; return total;

View File

@@ -28,31 +28,12 @@ ssize_t writev(
) )
{ {
ssize_t total; ssize_t total;
int v;
rtems_libio_t *iop; rtems_libio_t *iop;
total = rtems_libio_iovec_eval( fd, iov, iovcnt, LIBIO_FLAGS_WRITE, &iop ); total = rtems_libio_iovec_eval( fd, iov, iovcnt, LIBIO_FLAGS_WRITE, &iop );
if ( total > 0 ) { if ( total > 0 ) {
/* total = ( *iop->pathinfo.handlers->writev_h )( iop, iov, iovcnt, total );
* 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;
}
} }
return total; return total;

View File

@@ -35,6 +35,8 @@ libdefaultfs_a_SOURCES = \
src/defaults/default_handlers.c src/defaults/default_ops.c src/defaults/default_handlers.c src/defaults/default_ops.c
libdefaultfs_a_SOURCES += src/defaults/default_kqfilter.c libdefaultfs_a_SOURCES += src/defaults/default_kqfilter.c
libdefaultfs_a_SOURCES += src/defaults/default_poll.c libdefaultfs_a_SOURCES += src/defaults/default_poll.c
libdefaultfs_a_SOURCES += src/defaults/default_readv.c
libdefaultfs_a_SOURCES += src/defaults/default_writev.c
noinst_LIBRARIES += libimfs.a noinst_LIBRARIES += libimfs.a
libimfs_a_SOURCES = libimfs_a_SOURCES =

View File

@@ -32,5 +32,7 @@ const rtems_filesystem_file_handlers_r rtems_filesystem_handlers_default = {
.ftruncate_h = rtems_filesystem_default_ftruncate, .ftruncate_h = rtems_filesystem_default_ftruncate,
.fsync_h = rtems_filesystem_default_fsync_or_fdatasync, .fsync_h = rtems_filesystem_default_fsync_or_fdatasync,
.fdatasync_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
}; };

View File

@@ -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;
}

View File

@@ -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;
}

View File

@@ -52,7 +52,9 @@ const rtems_filesystem_file_handlers_r devFS_file_handlers = {
.ftruncate_h = rtems_filesystem_default_ftruncate, .ftruncate_h = rtems_filesystem_default_ftruncate,
.fsync_h = rtems_filesystem_default_fsync_or_fdatasync, .fsync_h = rtems_filesystem_default_fsync_or_fdatasync,
.fdatasync_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
}; };
int devFS_initialize( int devFS_initialize(

View File

@@ -22,15 +22,17 @@
#include "msdos.h" #include "msdos.h"
const rtems_filesystem_file_handlers_r msdos_dir_handlers = { const rtems_filesystem_file_handlers_r msdos_dir_handlers = {
rtems_filesystem_default_open, .open_h = rtems_filesystem_default_open,
rtems_filesystem_default_close, .close_h = rtems_filesystem_default_close,
msdos_dir_read, .read_h = msdos_dir_read,
rtems_filesystem_default_write, .write_h = rtems_filesystem_default_write,
rtems_filesystem_default_ioctl, .ioctl_h = rtems_filesystem_default_ioctl,
rtems_filesystem_default_lseek_directory, .lseek_h = rtems_filesystem_default_lseek_directory,
msdos_dir_stat, .fstat_h = msdos_dir_stat,
rtems_filesystem_default_ftruncate_directory, .ftruncate_h = rtems_filesystem_default_ftruncate_directory,
msdos_sync, .fsync_h = msdos_sync,
msdos_sync, .fdatasync_h = msdos_sync,
rtems_filesystem_default_fcntl .fcntl_h = rtems_filesystem_default_fcntl,
.readv_h = rtems_filesystem_default_readv,
.writev_h = rtems_filesystem_default_writev
}; };

View File

@@ -22,15 +22,17 @@
#include "msdos.h" #include "msdos.h"
const rtems_filesystem_file_handlers_r msdos_file_handlers = { const rtems_filesystem_file_handlers_r msdos_file_handlers = {
rtems_filesystem_default_open, .open_h = rtems_filesystem_default_open,
msdos_file_close, .close_h = msdos_file_close,
msdos_file_read, .read_h = msdos_file_read,
msdos_file_write, .write_h = msdos_file_write,
rtems_filesystem_default_ioctl, .ioctl_h = rtems_filesystem_default_ioctl,
rtems_filesystem_default_lseek_file, .lseek_h = rtems_filesystem_default_lseek_file,
msdos_file_stat, .fstat_h = msdos_file_stat,
msdos_file_ftruncate, .ftruncate_h = msdos_file_ftruncate,
msdos_file_sync, .fsync_h = msdos_file_sync,
msdos_sync, .fdatasync_h = msdos_sync,
rtems_filesystem_default_fcntl .fcntl_h = rtems_filesystem_default_fcntl,
.readv_h = rtems_filesystem_default_readv,
.writev_h = rtems_filesystem_default_writev
}; };

View File

@@ -113,17 +113,19 @@ static int IMFS_fifo_ioctl(
} }
static const rtems_filesystem_file_handlers_r IMFS_fifo_handlers = { static const rtems_filesystem_file_handlers_r IMFS_fifo_handlers = {
IMFS_fifo_open, .open_h = IMFS_fifo_open,
IMFS_fifo_close, .close_h = IMFS_fifo_close,
IMFS_fifo_read, .read_h = IMFS_fifo_read,
IMFS_fifo_write, .write_h = IMFS_fifo_write,
IMFS_fifo_ioctl, .ioctl_h = IMFS_fifo_ioctl,
rtems_filesystem_default_lseek, .lseek_h = rtems_filesystem_default_lseek,
IMFS_stat, .fstat_h = IMFS_stat,
rtems_filesystem_default_ftruncate, .ftruncate_h = rtems_filesystem_default_ftruncate,
rtems_filesystem_default_fsync_or_fdatasync, .fsync_h = rtems_filesystem_default_fsync_or_fdatasync,
rtems_filesystem_default_fsync_or_fdatasync, .fdatasync_h = rtems_filesystem_default_fsync_or_fdatasync,
rtems_filesystem_default_fcntl .fcntl_h = rtems_filesystem_default_fcntl,
.readv_h = rtems_filesystem_default_readv,
.writev_h = rtems_filesystem_default_writev
}; };
const IMFS_node_control IMFS_node_control_fifo = { const IMFS_node_control IMFS_node_control_fifo = {

View File

@@ -34,17 +34,19 @@ static int IMFS_stat_device(
} }
static const rtems_filesystem_file_handlers_r IMFS_device_handlers = { static const rtems_filesystem_file_handlers_r IMFS_device_handlers = {
device_open, .open_h = device_open,
device_close, .close_h = device_close,
device_read, .read_h = device_read,
device_write, .write_h = device_write,
device_ioctl, .ioctl_h = device_ioctl,
rtems_filesystem_default_lseek_file, .lseek_h = rtems_filesystem_default_lseek_file,
IMFS_stat_device, .fstat_h = IMFS_stat_device,
device_ftruncate, .ftruncate_h = device_ftruncate,
rtems_filesystem_default_fsync_or_fdatasync, .fsync_h = rtems_filesystem_default_fsync_or_fdatasync,
rtems_filesystem_default_fsync_or_fdatasync, .fdatasync_h = rtems_filesystem_default_fsync_or_fdatasync,
rtems_filesystem_default_fcntl .fcntl_h = rtems_filesystem_default_fcntl,
.readv_h = rtems_filesystem_default_readv,
.writev_h = rtems_filesystem_default_writev
}; };
static IMFS_jnode_t *IMFS_node_initialize_device( static IMFS_jnode_t *IMFS_node_initialize_device(

View File

@@ -50,17 +50,19 @@ static int IMFS_stat_directory(
} }
static const rtems_filesystem_file_handlers_r IMFS_directory_handlers = { static const rtems_filesystem_file_handlers_r IMFS_directory_handlers = {
rtems_filesystem_default_open, .open_h = rtems_filesystem_default_open,
rtems_filesystem_default_close, .close_h = rtems_filesystem_default_close,
imfs_dir_read, .read_h = imfs_dir_read,
rtems_filesystem_default_write, .write_h = rtems_filesystem_default_write,
rtems_filesystem_default_ioctl, .ioctl_h = rtems_filesystem_default_ioctl,
rtems_filesystem_default_lseek_directory, .lseek_h = rtems_filesystem_default_lseek_directory,
IMFS_stat_directory, .fstat_h = IMFS_stat_directory,
rtems_filesystem_default_ftruncate_directory, .ftruncate_h = rtems_filesystem_default_ftruncate_directory,
rtems_filesystem_default_fsync_or_fdatasync_success, .fsync_h = rtems_filesystem_default_fsync_or_fdatasync_success,
rtems_filesystem_default_fsync_or_fdatasync_success, .fdatasync_h = rtems_filesystem_default_fsync_or_fdatasync_success,
rtems_filesystem_default_fcntl .fcntl_h = rtems_filesystem_default_fcntl,
.readv_h = rtems_filesystem_default_readv,
.writev_h = rtems_filesystem_default_writev
}; };
static IMFS_jnode_t *IMFS_node_initialize_directory( static IMFS_jnode_t *IMFS_node_initialize_directory(

View File

@@ -45,17 +45,19 @@ static int IMFS_stat_link(
} }
static const rtems_filesystem_file_handlers_r IMFS_link_handlers = { static const rtems_filesystem_file_handlers_r IMFS_link_handlers = {
rtems_filesystem_default_open, .open_h = rtems_filesystem_default_open,
rtems_filesystem_default_close, .close_h = rtems_filesystem_default_close,
rtems_filesystem_default_read, .read_h = rtems_filesystem_default_read,
rtems_filesystem_default_write, .write_h = rtems_filesystem_default_write,
rtems_filesystem_default_ioctl, .ioctl_h = rtems_filesystem_default_ioctl,
rtems_filesystem_default_lseek, .lseek_h = rtems_filesystem_default_lseek,
IMFS_stat_link, .fstat_h = IMFS_stat_link,
rtems_filesystem_default_ftruncate, .ftruncate_h = rtems_filesystem_default_ftruncate,
rtems_filesystem_default_fsync_or_fdatasync, .fsync_h = rtems_filesystem_default_fsync_or_fdatasync,
rtems_filesystem_default_fsync_or_fdatasync, .fdatasync_h = rtems_filesystem_default_fsync_or_fdatasync,
rtems_filesystem_default_fcntl .fcntl_h = rtems_filesystem_default_fcntl,
.readv_h = rtems_filesystem_default_readv,
.writev_h = rtems_filesystem_default_writev
}; };
static IMFS_jnode_t *IMFS_node_initialize_hard_link( static IMFS_jnode_t *IMFS_node_initialize_hard_link(

View File

@@ -34,17 +34,19 @@ static int IMFS_stat_file(
} }
static const rtems_filesystem_file_handlers_r IMFS_memfile_handlers = { static const rtems_filesystem_file_handlers_r IMFS_memfile_handlers = {
memfile_open, .open_h = memfile_open,
rtems_filesystem_default_close, .close_h = rtems_filesystem_default_close,
memfile_read, .read_h = memfile_read,
memfile_write, .write_h = memfile_write,
rtems_filesystem_default_ioctl, .ioctl_h = rtems_filesystem_default_ioctl,
rtems_filesystem_default_lseek_file, .lseek_h = rtems_filesystem_default_lseek_file,
IMFS_stat_file, .fstat_h = IMFS_stat_file,
memfile_ftruncate, .ftruncate_h = memfile_ftruncate,
rtems_filesystem_default_fsync_or_fdatasync_success, .fsync_h = rtems_filesystem_default_fsync_or_fdatasync_success,
rtems_filesystem_default_fsync_or_fdatasync_success, .fdatasync_h = rtems_filesystem_default_fsync_or_fdatasync_success,
rtems_filesystem_default_fcntl .fcntl_h = rtems_filesystem_default_fcntl,
.readv_h = rtems_filesystem_default_readv,
.writev_h = rtems_filesystem_default_writev
}; };
const IMFS_node_control IMFS_node_control_memfile = { const IMFS_node_control IMFS_node_control_memfile = {

View File

@@ -516,7 +516,9 @@ static const rtems_filesystem_file_handlers_r rtems_jffs2_directory_handlers = {
.ftruncate_h = rtems_filesystem_default_ftruncate_directory, .ftruncate_h = rtems_filesystem_default_ftruncate_directory,
.fsync_h = rtems_filesystem_default_fsync_or_fdatasync, .fsync_h = rtems_filesystem_default_fsync_or_fdatasync,
.fdatasync_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 ssize_t rtems_jffs2_file_read(rtems_libio_t *iop, void *buf, size_t len) static ssize_t rtems_jffs2_file_read(rtems_libio_t *iop, void *buf, size_t len)
@@ -654,7 +656,9 @@ static const rtems_filesystem_file_handlers_r rtems_jffs2_file_handlers = {
.ftruncate_h = rtems_jffs2_file_ftruncate, .ftruncate_h = rtems_jffs2_file_ftruncate,
.fsync_h = rtems_filesystem_default_fsync_or_fdatasync, .fsync_h = rtems_filesystem_default_fsync_or_fdatasync,
.fdatasync_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 const rtems_filesystem_file_handlers_r rtems_jffs2_link_handlers = { static const rtems_filesystem_file_handlers_r rtems_jffs2_link_handlers = {
@@ -668,7 +672,9 @@ static const rtems_filesystem_file_handlers_r rtems_jffs2_link_handlers = {
.ftruncate_h = rtems_filesystem_default_ftruncate, .ftruncate_h = rtems_filesystem_default_ftruncate,
.fsync_h = rtems_filesystem_default_fsync_or_fdatasync, .fsync_h = rtems_filesystem_default_fsync_or_fdatasync,
.fdatasync_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 rtems_jffs2_set_location(rtems_filesystem_location_info_t *loc, struct _inode *inode) static void rtems_jffs2_set_location(rtems_filesystem_location_info_t *loc, struct _inode *inode)

View File

@@ -2869,7 +2869,9 @@ struct _rtems_filesystem_file_handlers_r nfs_file_file_handlers = {
.ftruncate_h = nfs_file_ftruncate, .ftruncate_h = nfs_file_ftruncate,
.fsync_h = rtems_filesystem_default_fsync_or_fdatasync, .fsync_h = rtems_filesystem_default_fsync_or_fdatasync,
.fdatasync_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
}; };
/* the directory handlers table */ /* the directory handlers table */
@@ -2885,7 +2887,9 @@ struct _rtems_filesystem_file_handlers_r nfs_dir_file_handlers = {
.ftruncate_h = rtems_filesystem_default_ftruncate_directory, .ftruncate_h = rtems_filesystem_default_ftruncate_directory,
.fsync_h = rtems_filesystem_default_fsync_or_fdatasync, .fsync_h = rtems_filesystem_default_fsync_or_fdatasync,
.fdatasync_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
}; };
/* the link handlers table */ /* the link handlers table */
@@ -2901,7 +2905,9 @@ struct _rtems_filesystem_file_handlers_r nfs_link_file_handlers = {
.ftruncate_h = rtems_filesystem_default_ftruncate, .ftruncate_h = rtems_filesystem_default_ftruncate,
.fsync_h = rtems_filesystem_default_fsync_or_fdatasync, .fsync_h = rtems_filesystem_default_fsync_or_fdatasync,
.fdatasync_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
}; };
/* we need a dummy driver entry table to get a /* we need a dummy driver entry table to get a

View File

@@ -193,5 +193,7 @@ const rtems_filesystem_file_handlers_r rtems_rfs_rtems_device_handlers = {
.ftruncate_h = rtems_rfs_rtems_device_ftruncate, .ftruncate_h = rtems_rfs_rtems_device_ftruncate,
.fsync_h = rtems_filesystem_default_fsync_or_fdatasync, .fsync_h = rtems_filesystem_default_fsync_or_fdatasync,
.fdatasync_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
}; };

View File

@@ -162,5 +162,7 @@ const rtems_filesystem_file_handlers_r rtems_rfs_rtems_dir_handlers = {
.ftruncate_h = rtems_filesystem_default_ftruncate_directory, .ftruncate_h = rtems_filesystem_default_ftruncate_directory,
.fsync_h = rtems_filesystem_default_fsync_or_fdatasync, .fsync_h = rtems_filesystem_default_fsync_or_fdatasync,
.fdatasync_h = rtems_rfs_rtems_fdatasync, .fdatasync_h = rtems_rfs_rtems_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
}; };

View File

@@ -353,5 +353,7 @@ const rtems_filesystem_file_handlers_r rtems_rfs_rtems_file_handlers = {
.ftruncate_h = rtems_rfs_rtems_file_ftruncate, .ftruncate_h = rtems_rfs_rtems_file_ftruncate,
.fsync_h = rtems_rfs_rtems_fdatasync, .fsync_h = rtems_rfs_rtems_fdatasync,
.fdatasync_h = rtems_rfs_rtems_fdatasync, .fdatasync_h = rtems_rfs_rtems_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
}; };

View File

@@ -780,7 +780,9 @@ const rtems_filesystem_file_handlers_r rtems_rfs_rtems_link_handlers =
.ftruncate_h = rtems_filesystem_default_ftruncate, .ftruncate_h = rtems_filesystem_default_ftruncate,
.fsync_h = rtems_filesystem_default_fsync_or_fdatasync, .fsync_h = rtems_filesystem_default_fsync_or_fdatasync,
.fdatasync_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
}; };
/** /**

View File

@@ -1412,7 +1412,9 @@ static const rtems_filesystem_file_handlers_r rtems_ftpfs_handlers = {
.ftruncate_h = rtems_ftpfs_ftruncate, .ftruncate_h = rtems_ftpfs_ftruncate,
.fsync_h = rtems_filesystem_default_fsync_or_fdatasync, .fsync_h = rtems_filesystem_default_fsync_or_fdatasync,
.fdatasync_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 const rtems_filesystem_file_handlers_r rtems_ftpfs_root_handlers = { static const rtems_filesystem_file_handlers_r rtems_ftpfs_root_handlers = {
@@ -1426,5 +1428,7 @@ static const rtems_filesystem_file_handlers_r rtems_ftpfs_root_handlers = {
.ftruncate_h = rtems_filesystem_default_ftruncate, .ftruncate_h = rtems_filesystem_default_ftruncate,
.fsync_h = rtems_filesystem_default_fsync_or_fdatasync, .fsync_h = rtems_filesystem_default_fsync_or_fdatasync,
.fdatasync_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
}; };

View File

@@ -1051,5 +1051,7 @@ static const rtems_filesystem_file_handlers_r rtems_tftp_handlers = {
.ftruncate_h = rtems_tftp_ftruncate, .ftruncate_h = rtems_tftp_ftruncate,
.fsync_h = rtems_filesystem_default_fsync_or_fdatasync, .fsync_h = rtems_filesystem_default_fsync_or_fdatasync,
.fdatasync_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
}; };

View File

@@ -812,15 +812,17 @@ rtems_bsdnet_fstat (const rtems_filesystem_location_info_t *loc, struct stat *sp
} }
static const rtems_filesystem_file_handlers_r socket_handlers = { static const rtems_filesystem_file_handlers_r socket_handlers = {
rtems_filesystem_default_open, /* open */ .open_h = rtems_filesystem_default_open,
rtems_bsdnet_close, /* close */ .close_h = rtems_bsdnet_close,
rtems_bsdnet_read, /* read */ .read_h = rtems_bsdnet_read,
rtems_bsdnet_write, /* write */ .write_h = rtems_bsdnet_write,
rtems_bsdnet_ioctl, /* ioctl */ .ioctl_h = rtems_bsdnet_ioctl,
rtems_filesystem_default_lseek, /* lseek */ .lseek_h = rtems_filesystem_default_lseek,
rtems_bsdnet_fstat, /* fstat */ .fstat_h = rtems_bsdnet_fstat,
rtems_filesystem_default_ftruncate, /* ftruncate */ .ftruncate_h = rtems_filesystem_default_ftruncate,
rtems_filesystem_default_fsync_or_fdatasync, /* fsync */ .fstat_h = rtems_filesystem_default_fsync_or_fdatasync,
rtems_filesystem_default_fsync_or_fdatasync, /* fdatasync */ .fdatasync_h = rtems_filesystem_default_fsync_or_fdatasync,
rtems_bsdnet_fcntl /* fcntl */ .fcntl_h = rtems_bsdnet_fcntl,
.readv_h = rtems_filesystem_default_readv,
.writev_h = rtems_filesystem_default_writev
}; };

View File

@@ -20,6 +20,7 @@
#include <sys/stat.h> #include <sys/stat.h>
#include <sys/ioctl.h> #include <sys/ioctl.h>
#include <sys/uio.h>
#include <fcntl.h> #include <fcntl.h>
#include <unistd.h> #include <unistd.h>
#include <errno.h> #include <errno.h>
@@ -41,6 +42,8 @@ typedef enum {
TEST_FSYNC, TEST_FSYNC,
TEST_FDATASYNC, TEST_FDATASYNC,
TEST_FCNTL, TEST_FCNTL,
TEST_READV,
TEST_WRITEV,
TEST_CLOSED, TEST_CLOSED,
TEST_FSTAT_UNLINK, TEST_FSTAT_UNLINK,
TEST_REMOVED, TEST_REMOVED,
@@ -68,7 +71,7 @@ static int handler_close(
{ {
test_state *state = IMFS_generic_get_context_by_iop(iop); test_state *state = IMFS_generic_get_context_by_iop(iop);
rtems_test_assert(*state == TEST_FCNTL); rtems_test_assert(*state == TEST_WRITEV);
*state = TEST_CLOSED; *state = TEST_CLOSED;
return 0; return 0;
@@ -202,6 +205,36 @@ static int handler_fcntl(
return 0; return 0;
} }
static ssize_t handler_readv(
rtems_libio_t *iop,
const struct iovec *iov,
int iovcnt,
ssize_t total
)
{
test_state *state = IMFS_generic_get_context_by_iop(iop);
rtems_test_assert(*state == TEST_FCNTL);
*state = TEST_READV;
return 0;
}
static ssize_t handler_writev(
rtems_libio_t *iop,
const struct iovec *iov,
int iovcnt,
ssize_t total
)
{
test_state *state = IMFS_generic_get_context_by_iop(iop);
rtems_test_assert(*state == TEST_READV);
*state = TEST_WRITEV;
return 0;
}
static const rtems_filesystem_file_handlers_r node_handlers = { static const rtems_filesystem_file_handlers_r node_handlers = {
.open_h = handler_open, .open_h = handler_open,
.close_h = handler_close, .close_h = handler_close,
@@ -213,7 +246,9 @@ static const rtems_filesystem_file_handlers_r node_handlers = {
.ftruncate_h = handler_ftruncate, .ftruncate_h = handler_ftruncate,
.fsync_h = handler_fsync, .fsync_h = handler_fsync,
.fdatasync_h = handler_fdatasync, .fdatasync_h = handler_fdatasync,
.fcntl_h = handler_fcntl .fcntl_h = handler_fcntl,
.readv_h = handler_readv,
.writev_h = handler_writev
}; };
static IMFS_jnode_t *node_initialize( static IMFS_jnode_t *node_initialize(
@@ -269,6 +304,10 @@ static void test_imfs_make_generic_node(void)
char buf [1]; char buf [1];
ssize_t n = 0; ssize_t n = 0;
off_t off = 0; off_t off = 0;
struct iovec iov = {
.iov_base = &buf [0],
.iov_len = (int) sizeof(buf)
};
rv = IMFS_make_generic_node( rv = IMFS_make_generic_node(
path, path,
@@ -305,6 +344,12 @@ static void test_imfs_make_generic_node(void)
rv = fcntl(fd, F_GETFD); rv = fcntl(fd, F_GETFD);
rtems_test_assert(rv >= 0); rtems_test_assert(rv >= 0);
rv = readv(fd, &iov, 1);
rtems_test_assert(rv == 0);
rv = writev(fd, &iov, 1);
rtems_test_assert(rv == 0);
rv = close(fd); rv = close(fd);
rtems_test_assert(rv == 0); rtems_test_assert(rv == 0);