summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--cpukit/libblock/src/blkdev-imfs.c2
-rw-r--r--cpukit/libcsupport/include/rtems/libio.h4
-rw-r--r--cpukit/libcsupport/src/read.c8
-rw-r--r--cpukit/libcsupport/src/readv.c1
-rw-r--r--cpukit/libcsupport/src/sup_fs_deviceio.c4
-rw-r--r--cpukit/libcsupport/src/write.c8
-rw-r--r--cpukit/libcsupport/src/writev.c1
-rw-r--r--cpukit/libfs/src/dosfs/msdos_file.c7
-rw-r--r--cpukit/libfs/src/imfs/memfile.c11
-rw-r--r--cpukit/libfs/src/nfsclient/src/nfs.c6
-rw-r--r--cpukit/libfs/src/rfs/rtems-rfs-rtems-file.c7
11 files changed, 39 insertions, 20 deletions
diff --git a/cpukit/libblock/src/blkdev-imfs.c b/cpukit/libblock/src/blkdev-imfs.c
index 86455930f6..c69542d531 100644
--- a/cpukit/libblock/src/blkdev-imfs.c
+++ b/cpukit/libblock/src/blkdev-imfs.c
@@ -75,6 +75,7 @@ static ssize_t rtems_blkdev_imfs_read(
}
if (remaining >= 0) {
+ iop->offset += count;
rv = (ssize_t) count;
} else {
errno = EIO;
@@ -134,6 +135,7 @@ static ssize_t rtems_blkdev_imfs_write(
}
if (remaining >= 0) {
+ iop->offset += count;
rv = (ssize_t) count;
} else {
errno = EIO;
diff --git a/cpukit/libcsupport/include/rtems/libio.h b/cpukit/libcsupport/include/rtems/libio.h
index 9268aed2e1..b42ff93dec 100644
--- a/cpukit/libcsupport/include/rtems/libio.h
+++ b/cpukit/libcsupport/include/rtems/libio.h
@@ -786,6 +786,8 @@ typedef int (*rtems_filesystem_close_t)(
/**
* @brief Reads from a node.
*
+ * This handler is responsible to update the offset field of the IO descriptor.
+ *
* @param[in, out] iop The IO pointer.
* @param[out] buffer The buffer for read data.
* @param[in] count The size of the buffer in characters.
@@ -804,6 +806,8 @@ typedef ssize_t (*rtems_filesystem_read_t)(
/**
* @brief Writes to a node.
*
+ * This handler is responsible to update the offset field of the IO descriptor.
+ *
* @param[in, out] iop The IO pointer.
* @param[out] buffer The buffer for write data.
* @param[in] count The size of the buffer in characters.
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;
}
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;
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;
}
diff --git a/cpukit/libfs/src/nfsclient/src/nfs.c b/cpukit/libfs/src/nfsclient/src/nfs.c
index 1e25165bfc..95613c0222 100644
--- a/cpukit/libfs/src/nfsclient/src/nfs.c
+++ b/cpukit/libfs/src/nfsclient/src/nfs.c
@@ -2311,6 +2311,10 @@ static ssize_t nfs_file_read(
}
} while (count > 0);
+ if (rv > 0) {
+ iop->offset = offset;
+ }
+
return rv;
}
@@ -2419,6 +2423,8 @@ int e;
node->age = nowSeconds();
+ iop->offset += count;
+
return count;
}
diff --git a/cpukit/libfs/src/rfs/rtems-rfs-rtems-file.c b/cpukit/libfs/src/rfs/rtems-rfs-rtems-file.c
index 525dceec1d..7de04038e7 100644
--- a/cpukit/libfs/src/rfs/rtems-rfs-rtems-file.c
+++ b/cpukit/libfs/src/rfs/rtems-rfs-rtems-file.c
@@ -163,6 +163,9 @@ rtems_rfs_rtems_file_read (rtems_libio_t* iop,
}
}
+ if (read >= 0)
+ iop->offset = pos + read;
+
rtems_rfs_rtems_unlock (rtems_rfs_file_fs (file));
return read;
@@ -220,7 +223,6 @@ rtems_rfs_rtems_file_write (rtems_libio_t* iop,
rtems_rfs_rtems_unlock (rtems_rfs_file_fs (file));
return rtems_rfs_rtems_error ("file-write: write append seek", rc);
}
- iop->offset = pos;
}
while (count)
@@ -251,6 +253,9 @@ rtems_rfs_rtems_file_write (rtems_libio_t* iop,
}
}
+ if (write >= 0)
+ iop->offset = pos + write;
+
rtems_rfs_rtems_unlock (rtems_rfs_file_fs (file));
return write;