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/dosfs/msdos_file.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'cpukit/libfs/src/dosfs/msdos_file.c') diff --git a/cpukit/libfs/src/dosfs/msdos_file.c b/cpukit/libfs/src/dosfs/msdos_file.c index ac09e0fbbb..e20b71b8e6 100644 --- a/cpukit/libfs/src/dosfs/msdos_file.c +++ b/cpukit/libfs/src/dosfs/msdos_file.c @@ -117,6 +117,8 @@ msdos_file_read(rtems_libio_t *iop, void *buffer, size_t count) ret = fat_file_read(iop->pathinfo.mt_entry, fat_fd, iop->offset, count, buffer); + if (ret > 0) + iop->offset += ret; rtems_semaphore_release(fs_info->vol_sema); return ret; @@ -163,8 +165,9 @@ msdos_file_write(rtems_libio_t *iop,const void *buffer, size_t count) * update file size in both fat-file descriptor and file control block if * file was extended */ - if (iop->offset + ret > fat_fd->fat_file_size) - fat_fd->fat_file_size = iop->offset + ret; + iop->offset += ret; + if (iop->offset > fat_fd->fat_file_size) + fat_fd->fat_file_size = iop->offset; rtems_semaphore_release(fs_info->vol_sema); return ret; -- cgit v1.2.3