From 53da07e436df21f078de665d90442ee5c7166ab7 Mon Sep 17 00:00:00 2001 From: Sebastian Huber Date: Mon, 14 May 2012 15:21:30 +0200 Subject: Filesystem: PR1255: Move offset update to handlers It is now the responsibility of the read() and write() handler to update the offset field of the IO descriptor (rtems_libio_t). This change makes it possible to protect the IO descriptor from concurrent access by per file locks. --- cpukit/libcsupport/src/read.c | 8 +------- cpukit/libcsupport/src/readv.c | 1 - cpukit/libcsupport/src/sup_fs_deviceio.c | 4 ++++ cpukit/libcsupport/src/write.c | 8 +------- cpukit/libcsupport/src/writev.c | 1 - 5 files changed, 6 insertions(+), 16 deletions(-) (limited to 'cpukit/libcsupport/src') diff --git a/cpukit/libcsupport/src/read.c b/cpukit/libcsupport/src/read.c index 759133b0cb..ee10166dc8 100644 --- a/cpukit/libcsupport/src/read.c +++ b/cpukit/libcsupport/src/read.c @@ -22,7 +22,6 @@ ssize_t read( size_t count ) { - ssize_t rc; rtems_libio_t *iop; rtems_libio_check_fd( fd ); @@ -35,12 +34,7 @@ ssize_t read( /* * Now process the read(). */ - rc = (*iop->pathinfo.handlers->read_h)( iop, buffer, count ); - - if ( rc > 0 ) - iop->offset += rc; - - return rc; + return (*iop->pathinfo.handlers->read_h)( iop, buffer, count ); } /* diff --git a/cpukit/libcsupport/src/readv.c b/cpukit/libcsupport/src/readv.c index b23abd0b82..4e540d5da4 100644 --- a/cpukit/libcsupport/src/readv.c +++ b/cpukit/libcsupport/src/readv.c @@ -106,7 +106,6 @@ ssize_t readv( return -1; if ( bytes > 0 ) { - iop->offset += bytes; total += bytes; } diff --git a/cpukit/libcsupport/src/sup_fs_deviceio.c b/cpukit/libcsupport/src/sup_fs_deviceio.c index aeff60ea83..74f92cb44c 100644 --- a/cpukit/libcsupport/src/sup_fs_deviceio.c +++ b/cpukit/libcsupport/src/sup_fs_deviceio.c @@ -72,6 +72,8 @@ ssize_t rtems_deviceio_read( status = rtems_io_read( major, minor, &args ); if ( status == RTEMS_SUCCESSFUL ) { + iop->offset += args.bytes_moved; + return (ssize_t) args.bytes_moved; } else { return rtems_deviceio_errno( status ); @@ -98,6 +100,8 @@ ssize_t rtems_deviceio_write( status = rtems_io_write( major, minor, &args ); if ( status == RTEMS_SUCCESSFUL ) { + iop->offset += args.bytes_moved; + return (ssize_t) args.bytes_moved; } else { return rtems_deviceio_errno( status ); diff --git a/cpukit/libcsupport/src/write.c b/cpukit/libcsupport/src/write.c index b74738845b..dc1255867d 100644 --- a/cpukit/libcsupport/src/write.c +++ b/cpukit/libcsupport/src/write.c @@ -29,7 +29,6 @@ ssize_t write( size_t count ) { - ssize_t rc; rtems_libio_t *iop; rtems_libio_check_fd( fd ); @@ -42,10 +41,5 @@ ssize_t write( /* * Now process the write() request. */ - rc = (*iop->pathinfo.handlers->write_h)( iop, buffer, count ); - - if ( rc > 0 ) - iop->offset += rc; - - return rc; + return (*iop->pathinfo.handlers->write_h)( iop, buffer, count ); } diff --git a/cpukit/libcsupport/src/writev.c b/cpukit/libcsupport/src/writev.c index 8356c1ee66..47605a4cd9 100644 --- a/cpukit/libcsupport/src/writev.c +++ b/cpukit/libcsupport/src/writev.c @@ -113,7 +113,6 @@ ssize_t writev( return -1; if ( bytes > 0 ) { - iop->offset += bytes; total += bytes; } -- cgit v1.2.3