diff options
author | Chris Johns <chrisj@rtems.org> | 2011-03-14 05:07:19 +0000 |
---|---|---|
committer | Chris Johns <chrisj@rtems.org> | 2011-03-14 05:07:19 +0000 |
commit | d991d2f194b9e510630ef1223780a35718b79bfd (patch) | |
tree | 83366501e675b2719151ab1159ad7a6195c47efb /cpukit/libfs/src/rfs/rtems-rfs-rtems-file.c | |
parent | Regenerate. (diff) | |
download | rtems-d991d2f194b9e510630ef1223780a35718b79bfd.tar.bz2 |
2011-03-14 Chris Johns <chrisj@rtems.org>
PR 1757/filesystem
* libfs/src/rfs/rtems-rfs-block-pos.h,
libfs/src/rfs/rtems-rfs-block.h, libfs/src/rfs/rtems-rfs-file.c,
libfs/src/rfs/rtems-rfs-rtems-file.c: Set the file size in
iop-size when a file is open. Fix lseek to end of file then write
for sizes less than half the file system block size.
Diffstat (limited to '')
-rw-r--r-- | cpukit/libfs/src/rfs/rtems-rfs-rtems-file.c | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/cpukit/libfs/src/rfs/rtems-rfs-rtems-file.c b/cpukit/libfs/src/rfs/rtems-rfs-rtems-file.c index 5be618d8c6..90ef639300 100644 --- a/cpukit/libfs/src/rfs/rtems-rfs-rtems-file.c +++ b/cpukit/libfs/src/rfs/rtems-rfs-rtems-file.c @@ -70,6 +70,7 @@ rtems_rfs_rtems_file_open (rtems_libio_t* iop, if (rtems_rfs_rtems_trace (RTEMS_RFS_RTEMS_DEBUG_FILE_OPEN)) printf("rtems-rfs: file-open: handle:%p\n", file); + iop->size = rtems_rfs_file_size (file); iop->file_info = file; rtems_rfs_rtems_unlock (fs); @@ -195,21 +196,25 @@ rtems_rfs_rtems_file_write (rtems_libio_t* iop, pos = iop->offset; /* - * If the iop position is past the physical end of the file we need to set the - * file size to the new length before writing. + * If the iop position is past the physical end of the file we need to set + * the file size to the new length before writing. If the position equals the + * size of file we are still past the end of the file as positions number + * from 0. For a specific position we need a file that has a length of one + * more. */ - if (pos > rtems_rfs_file_size (file)) + if (pos >= rtems_rfs_file_size (file)) { - rc = rtems_rfs_file_set_size (file, pos); + rc = rtems_rfs_file_set_size (file, pos + 1); if (rc) { rtems_rfs_rtems_unlock (rtems_rfs_file_fs (file)); return rtems_rfs_rtems_error ("file-write: write extend", rc); } - rtems_rfs_file_set_bpos (file, pos); } + rtems_rfs_file_set_bpos (file, pos); + while (count) { size_t size = count; |