Ignore:
Timestamp:
May 14, 2012, 1:19:20 PM (7 years ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
4.11, master
Children:
53da07e
Parents:
df01da67
git-author:
Sebastian Huber <sebastian.huber@…> (05/14/12 13:19:20)
git-committer:
Sebastian Huber <sebastian.huber@…> (05/15/12 08:01:42)
Message:

Filesystem: Add shared device IO support

The device IO file system support in IMFS, devFS, and RFS uses now a
shared implementation.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • cpukit/libfs/src/rfs/rtems-rfs-rtems-dev.c

    rdf01da67 rfed66f99  
    1919
    2020#if HAVE_CONFIG_H
    21 #include "config.h"
     21  #include "config.h"
    2222#endif
    2323
    24 #include <rtems/devfs.h>
    2524#include "rtems-rfs-rtems.h"
     25
     26#include <rtems/deviceio.h>
    2627
    2728static void
     
    4950                              mode_t         mode)
    5051{
    51   rtems_libio_open_close_args_t args;
    5252  rtems_rfs_file_system*        fs = rtems_rfs_rtems_pathloc_dev (&iop->pathinfo);
    5353  rtems_rfs_ino                 ino = rtems_rfs_rtems_get_iop_ino (iop);
     
    5555  rtems_device_major_number     major;
    5656  rtems_device_minor_number     minor;
    57   rtems_status_code             status;
    5857  int                           rc;
    5958
     
    8281  iop->data1 = (void *) minor;
    8382
    84   args.iop   = iop;
    85   args.flags = iop->flags;
    86   args.mode  = mode;
    87 
    88   status = rtems_io_open (major, minor, (void *) &args);
    89 
    90   return rtems_deviceio_errno (status);
     83  return rtems_deviceio_open (iop, pathname, oflag, mode, minor, major);
    9184}
    9285
     
    10194rtems_rfs_rtems_device_close (rtems_libio_t* iop)
    10295{
    103   rtems_libio_open_close_args_t args;
    104   rtems_status_code             status;
    10596  rtems_device_major_number     major;
    10697  rtems_device_minor_number     minor;
     
    10899  rtems_rfs_rtems_device_get_major_and_minor (iop, &major, &minor);
    109100
    110   args.iop   = iop;
    111   args.flags = 0;
    112   args.mode  = 0;
    113 
    114   status = rtems_io_close (major, minor, (void *) &args);
    115 
    116   return rtems_deviceio_errno (status);
     101  return rtems_deviceio_close (iop, major, minor);
    117102}
    118103
     
    129114rtems_rfs_rtems_device_read (rtems_libio_t* iop, void* buffer, size_t count)
    130115{
    131   rtems_libio_rw_args_t     args;
    132   rtems_status_code         status;
    133116  rtems_device_major_number major;
    134117  rtems_device_minor_number minor;
     
    136119  rtems_rfs_rtems_device_get_major_and_minor (iop, &major, &minor);
    137120
    138   args.iop         = iop;
    139   args.offset      = iop->offset;
    140   args.buffer      = buffer;
    141   args.count       = count;
    142   args.flags       = iop->flags;
    143   args.bytes_moved = 0;
    144 
    145   status = rtems_io_read (major, minor, (void *) &args);
    146   if (status)
    147     return rtems_deviceio_errno (status);
    148 
    149   return (ssize_t) args.bytes_moved;
     121  return rtems_deviceio_read (iop, buffer, count, major, minor);
    150122}
    151123
     
    164136                              size_t         count)
    165137{
    166   rtems_libio_rw_args_t     args;
    167   rtems_status_code         status;
    168138  rtems_device_major_number major;
    169139  rtems_device_minor_number minor;
     
    171141  rtems_rfs_rtems_device_get_major_and_minor (iop, &major, &minor);
    172142
    173   args.iop         = iop;
    174   args.offset      = iop->offset;
    175   args.buffer      = (void *) buffer;
    176   args.count       = count;
    177   args.flags       = iop->flags;
    178   args.bytes_moved = 0;
    179 
    180   status = rtems_io_write (major, minor, (void *) &args);
    181   if (status)
    182     return rtems_deviceio_errno (status);
    183 
    184   return (ssize_t) args.bytes_moved;
     143  return rtems_deviceio_write (iop, buffer, count, major, minor);
    185144}
    186145
     
    199158                              void*           buffer)
    200159{
    201   rtems_libio_ioctl_args_t  args;
    202   rtems_status_code         status;
    203160  rtems_device_major_number major;
    204161  rtems_device_minor_number minor;
     
    206163  rtems_rfs_rtems_device_get_major_and_minor (iop, &major, &minor);
    207164
    208   args.iop     = iop;
    209   args.command = command;
    210   args.buffer  = buffer;
    211 
    212   status = rtems_io_control (major, minor, (void *) &args);
    213   if (status)
    214     return rtems_deviceio_errno (status);
    215 
    216   return args.ioctl_return;
     165  return rtems_deviceio_control (iop, command, buffer, major, minor);
    217166}
    218167
Note: See TracChangeset for help on using the changeset viewer.