changeset 1975:187dfdcdf712

* src/fatfs_supp.c: lseek returned EEOF when at the end of the file rather than the current position.
author asl
date Tue, 07 Jun 2005 09:45:52 +0000
parents 3038ada9d671
children 8438b097ea3b
files packages/fs/fat/current/ChangeLog packages/fs/fat/current/src/fatfs_supp.c
diffstat 2 files changed, 17 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/packages/fs/fat/current/ChangeLog
+++ b/packages/fs/fat/current/ChangeLog
@@ -1,3 +1,8 @@
+2005-06-07  Savin Zlobec  <savin@elatec.si>
+
+	* src/fatfs_supp.c: lseek returned EEOF when at the end of the
+	file rather than the current position. 
+
 2005-03-27  Andrew Lunn  <andrew.lunn@ascom.ch>
 
 	* tests/fatfs1.c: Fixed various compiler warnings about types passed to
--- a/packages/fs/fat/current/src/fatfs_supp.c
+++ b/packages/fs/fat/current/src/fatfs_supp.c
@@ -1172,8 +1172,10 @@ get_position_from_off(fatfs_disk_t     *
     // Err could be EEOF wich means that the given 
     // offset if out of given file (cluster chain)
 
-    if (ENOERR == err)
-        *pos = new_pos; 
+    if (EEOF == err)
+        new_pos.cluster_pos = disk->cluster_size; 
+    
+    *pos = new_pos; 
     
     return err;
 } 
@@ -2056,11 +2058,18 @@ fatfs_setpos(fatfs_disk_t      *disk,
              fatfs_data_pos_t  *pos,
              cyg_uint32         offset)
 {
+    int err;
+    
     CYG_CHECK_DATA_PTRC(disk);
     CYG_CHECK_DATA_PTRC(file);
     CYG_CHECK_DATA_PTRC(pos);
     
-    return get_position_from_off(disk, file->cluster, offset, pos, CO_NONE);
+    err = get_position_from_off(disk, file->cluster, offset, pos, CO_NONE);
+
+    if (EEOF == err && offset == file->size)
+        return ENOERR;
+    else
+        return err;
 }
 
 // -------------------------------------------------------------------------