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/libfs/src/imfs/memfile.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'cpukit/libfs/src/imfs/memfile.c') diff --git a/cpukit/libfs/src/imfs/memfile.c b/cpukit/libfs/src/imfs/memfile.c index fcbeed96b3..2eb7949275 100644 --- a/cpukit/libfs/src/imfs/memfile.c +++ b/cpukit/libfs/src/imfs/memfile.c @@ -121,10 +121,16 @@ ssize_t memfile_read( ) { IMFS_jnode_t *the_jnode; + ssize_t status; the_jnode = iop->pathinfo.node_access; - return IMFS_memfile_read( the_jnode, iop->offset, buffer, count ); + status = IMFS_memfile_read( the_jnode, iop->offset, buffer, count ); + + if ( status > 0 ) + iop->offset += status; + + return status; } /* @@ -148,6 +154,9 @@ ssize_t memfile_write( status = IMFS_memfile_write( the_jnode, iop->offset, buffer, count ); + if ( status > 0 ) + iop->offset += status; + return status; } -- cgit v1.2.3