Changeset 2f68778 in rtems for testsuites/fstests


Ignore:
Timestamp:
Dec 16, 2013, 12:44:13 PM (6 years ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
4.11, master
Children:
56bea43
Parents:
95a57280
git-author:
Sebastian Huber <sebastian.huber@…> (12/16/13 12:44:13)
git-committer:
Sebastian Huber <sebastian.huber@…> (12/20/13 09:31:53)
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • testsuites/fstests/fsimfsgeneric01/init.c

    r95a57280 r2f68778  
    2121#include <sys/stat.h>
    2222#include <sys/ioctl.h>
     23#include <sys/uio.h>
    2324#include <fcntl.h>
    2425#include <unistd.h>
     
    4243  TEST_FDATASYNC,
    4344  TEST_FCNTL,
     45  TEST_READV,
     46  TEST_WRITEV,
    4447  TEST_CLOSED,
    4548  TEST_FSTAT_UNLINK,
     
    6972  test_state *state = IMFS_generic_get_context_by_iop(iop);
    7073
    71   rtems_test_assert(*state == TEST_FCNTL);
     74  rtems_test_assert(*state == TEST_WRITEV);
    7275  *state = TEST_CLOSED;
    7376
     
    203206}
    204207
     208static ssize_t handler_readv(
     209  rtems_libio_t *iop,
     210  const struct iovec *iov,
     211  int iovcnt,
     212  ssize_t total
     213)
     214{
     215  test_state *state = IMFS_generic_get_context_by_iop(iop);
     216
     217  rtems_test_assert(*state == TEST_FCNTL);
     218  *state = TEST_READV;
     219
     220  return 0;
     221}
     222
     223static ssize_t handler_writev(
     224  rtems_libio_t *iop,
     225  const struct iovec *iov,
     226  int iovcnt,
     227  ssize_t total
     228)
     229{
     230  test_state *state = IMFS_generic_get_context_by_iop(iop);
     231
     232  rtems_test_assert(*state == TEST_READV);
     233  *state = TEST_WRITEV;
     234
     235  return 0;
     236}
     237
    205238static const rtems_filesystem_file_handlers_r node_handlers = {
    206239  .open_h = handler_open,
     
    214247  .fsync_h = handler_fsync,
    215248  .fdatasync_h = handler_fdatasync,
    216   .fcntl_h = handler_fcntl
     249  .fcntl_h = handler_fcntl,
     250  .readv_h = handler_readv,
     251  .writev_h = handler_writev
    217252};
    218253
     
    270305  ssize_t n = 0;
    271306  off_t off = 0;
     307  struct iovec iov = {
     308    .iov_base = &buf [0],
     309    .iov_len = (int) sizeof(buf)
     310  };
    272311
    273312  rv = IMFS_make_generic_node(
     
    305344  rv = fcntl(fd, F_GETFD);
    306345  rtems_test_assert(rv >= 0);
     346
     347  rv = readv(fd, &iov, 1);
     348  rtems_test_assert(rv == 0);
     349
     350  rv = writev(fd, &iov, 1);
     351  rtems_test_assert(rv == 0);
    307352
    308353  rv = close(fd);
Note: See TracChangeset for help on using the changeset viewer.