summaryrefslogtreecommitdiffstats
path: root/c/src/exec/libcsupport/src/write.c
diff options
context:
space:
mode:
Diffstat (limited to 'c/src/exec/libcsupport/src/write.c')
-rw-r--r--c/src/exec/libcsupport/src/write.c17
1 files changed, 9 insertions, 8 deletions
diff --git a/c/src/exec/libcsupport/src/write.c b/c/src/exec/libcsupport/src/write.c
index 7e0953bb90..3de21f0d0f 100644
--- a/c/src/exec/libcsupport/src/write.c
+++ b/c/src/exec/libcsupport/src/write.c
@@ -34,15 +34,22 @@ int write( /* XXX this should return a ssize_t */
rtems_status_code rc;
rtems_libio_t *iop;
+ rtems_libio_check_fd( fd );
+ iop = rtems_libio_iop( fd );
+ rtems_libio_check_buffer( buffer );
+ rtems_libio_check_count( count );
+ rtems_libio_check_permissions( iop, LIBIO_FLAGS_WRITE );
+
/*
* If this file descriptor is mapped to an external set of handlers,
* then pass the request on to them.
*/
- if ( rtems_file_descriptor_type( fd ) ) {
+ if ( iop->flags & LIBIO_FLAGS_HANDLER_MASK ) {
rtems_libio_write_t fp;
- fp = rtems_libio_handlers[rtems_file_descriptor_type_index(fd)].write;
+ fp = rtems_libio_handlers[
+ (iop->flags >> LIBIO_FLAGS_HANDLER_SHIFT) - 1].write;
if ( fp == NULL )
set_errno_and_return_minus_one( EBADF );
@@ -53,12 +60,6 @@ int write( /* XXX this should return a ssize_t */
* Now process the write() request.
*/
- iop = rtems_libio_iop( fd );
- rtems_libio_check_fd( fd );
- rtems_libio_check_buffer( buffer );
- rtems_libio_check_count( count );
- rtems_libio_check_permissions( iop, LIBIO_FLAGS_WRITE );
-
if ( !iop->handlers->write )
set_errno_and_return_minus_one( ENOTSUP );