summaryrefslogtreecommitdiffstats
path: root/cpukit/libfs/src/imfs/deviceio.c
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2012-05-14 15:19:20 +0200
committerSebastian Huber <sebastian.huber@embedded-brains.de>2012-05-15 10:01:42 +0200
commitfed66f991014f40430b256d44231a7828bb8a413 (patch)
tree776084d409f4c21ed84c1c2da4d65993f10ef588 /cpukit/libfs/src/imfs/deviceio.c
parentFilesystem: Use ioctl_command_t (diff)
downloadrtems-fed66f991014f40430b256d44231a7828bb8a413.tar.bz2
Filesystem: Add shared device IO support
The device IO file system support in IMFS, devFS, and RFS uses now a shared implementation.
Diffstat (limited to 'cpukit/libfs/src/imfs/deviceio.c')
-rw-r--r--cpukit/libfs/src/imfs/deviceio.c140
1 files changed, 26 insertions, 114 deletions
diff --git a/cpukit/libfs/src/imfs/deviceio.c b/cpukit/libfs/src/imfs/deviceio.c
index 60a66f3f3d..679f94559c 100644
--- a/cpukit/libfs/src/imfs/deviceio.c
+++ b/cpukit/libfs/src/imfs/deviceio.c
@@ -4,7 +4,7 @@
* This file contains the set of handlers used to map operations on
* IMFS device nodes onto calls to the RTEMS Classic API IO Manager.
*
- * COPYRIGHT (c) 1989-2008.
+ * COPYRIGHT (c) 1989-2012.
* On-Line Applications Research Corporation (OAR).
*
* The license and distribution terms for this file may be
@@ -18,13 +18,7 @@
#include "imfs.h"
-#include <rtems/devfs.h>
-
-/*
- * device_open
- *
- * This handler maps an open() operation onto rtems_io_open().
- */
+#include <rtems/deviceio.h>
int device_open(
rtems_libio_t *iop,
@@ -33,174 +27,92 @@ int device_open(
mode_t mode
)
{
- rtems_libio_open_close_args_t args;
- rtems_status_code status;
IMFS_jnode_t *the_jnode;
the_jnode = iop->pathinfo.node_access;
- args.iop = iop;
- args.flags = iop->flags;
- args.mode = mode;
-
- status = rtems_io_open(
+ return rtems_deviceio_open(
+ iop,
+ pathname,
+ oflag,
+ mode,
the_jnode->info.device.major,
- the_jnode->info.device.minor,
- (void *) &args
+ the_jnode->info.device.minor
);
-
- return rtems_deviceio_errno( status );
}
-/*
- * device_close
- *
- * This handler maps a close() operation onto rtems_io_close().
- */
-
int device_close(
rtems_libio_t *iop
)
{
- rtems_libio_open_close_args_t args;
- rtems_status_code status;
IMFS_jnode_t *the_jnode;
the_jnode = iop->pathinfo.node_access;
- args.iop = iop;
- args.flags = 0;
- args.mode = 0;
-
- status = rtems_io_close(
+ return rtems_deviceio_close(
+ iop,
the_jnode->info.device.major,
- the_jnode->info.device.minor,
- (void *) &args
+ the_jnode->info.device.minor
);
-
- return rtems_deviceio_errno( status );
}
-/*
- * device_read
- *
- * This handler maps a read() operation onto rtems_io_read().
- */
-
ssize_t device_read(
rtems_libio_t *iop,
void *buffer,
size_t count
)
{
- rtems_libio_rw_args_t args;
- rtems_status_code status;
IMFS_jnode_t *the_jnode;
the_jnode = iop->pathinfo.node_access;
- args.iop = iop;
- args.offset = iop->offset;
- args.buffer = buffer;
- args.count = count;
- args.flags = iop->flags;
- args.bytes_moved = 0;
-
- status = rtems_io_read(
+ return rtems_deviceio_read(
+ iop,
+ buffer,
+ count,
the_jnode->info.device.major,
- the_jnode->info.device.minor,
- (void *) &args
+ the_jnode->info.device.minor
);
-
- if ( status )
- return rtems_deviceio_errno(status);
-
- return (ssize_t) args.bytes_moved;
}
-/*
- * device_write
- *
- * This handler maps a write() operation onto rtems_io_write().
- */
-
ssize_t device_write(
rtems_libio_t *iop,
const void *buffer,
size_t count
)
{
- rtems_libio_rw_args_t args;
- rtems_status_code status;
IMFS_jnode_t *the_jnode;
the_jnode = iop->pathinfo.node_access;
- args.iop = iop;
- args.offset = iop->offset;
- args.buffer = (void *) buffer;
- args.count = count;
- args.flags = iop->flags;
- args.bytes_moved = 0;
-
- status = rtems_io_write(
+ return rtems_deviceio_write(
+ iop,
+ buffer,
+ count,
the_jnode->info.device.major,
- the_jnode->info.device.minor,
- (void *) &args
+ the_jnode->info.device.minor
);
-
- if ( status )
- return rtems_deviceio_errno(status);
-
- return (ssize_t) args.bytes_moved;
}
-/*
- * device_ioctl
- *
- * This handler maps an ioctl() operation onto rtems_io_ioctl().
- */
-
int device_ioctl(
rtems_libio_t *iop,
ioctl_command_t command,
void *buffer
)
{
- rtems_libio_ioctl_args_t args;
- rtems_status_code status;
IMFS_jnode_t *the_jnode;
- args.iop = iop;
- args.command = command;
- args.buffer = buffer;
-
the_jnode = iop->pathinfo.node_access;
- status = rtems_io_control(
+ return rtems_deviceio_control(
+ iop,
+ command,
+ buffer,
the_jnode->info.device.major,
- the_jnode->info.device.minor,
- (void *) &args
+ the_jnode->info.device.minor
);
-
- if ( status )
- return rtems_deviceio_errno(status);
-
- return args.ioctl_return;
}
-/*
- * device_stat
- *
- * The IMFS_stat() is used.
- */
-
-/*
- * device_rmnod
- *
- * The IMFS_rmnod() is used.
- */
-
int device_ftruncate(
rtems_libio_t *iop,
off_t length