logo       
Google Custom Search
    AddThis Social Bookmark Button
-->

cvs: firmware/common file.c,1.46,1.47: msg#00051

Subject: cvs: firmware/common file.c,1.46,1.47
Update of /cvsroot/rockbox/firmware/common
In directory sc8-pr-cvs1:/tmp/cvs-serv6858

Modified Files:
        file.c 
Log Message:
Update fileoffset and cacheoffset on error.

Index: file.c
===================================================================
RCS file: /cvsroot/rockbox/firmware/common/file.c,v
retrieving revision 1.46
retrieving revision 1.47
diff -u -b -r1.46 -r1.47
--- file.c      18 Mar 2003 00:38:12 -0000      1.46
+++ file.c      15 Apr 2003 08:07:50 -0000      1.47
@@ -421,11 +421,12 @@
     /* read whole sectors right into the supplied buffer */
     sectors = count / SECTOR_SIZE;
     if ( sectors ) {
-        int rc = fat_readwrite(&(file->fatfile), sectors, 
-                               buf+nread, write );
+        int rc = fat_readwrite(&(file->fatfile), sectors, buf+nread, write );
         if ( rc < 0 ) {
             DEBUGF("Failed read/writing %d sectors\n",sectors);
             errno = EIO;
+            file->fileoffset += nread;
+            file->cacheoffset = -1;
             return nread ? nread : rc * 10 - 4;
         }
         else {
@@ -453,11 +454,12 @@
                 /* sector is only partially filled. copy-back from disk */
                 int rc;
                 LDEBUGF("Copy-back tail cache\n");
-                rc = fat_readwrite(&(file->fatfile), 1,
-                                   file->cache, false );
+                rc = fat_readwrite(&(file->fatfile), 1, file->cache, false );
                 if ( rc < 0 ) {
                     DEBUGF("Failed writing\n");
                     errno = EIO;
+                    file->fileoffset += nread;
+                    file->cacheoffset = -1;
                     return nread ? nread : rc * 10 - 5;
                 }
                 /* seek back one sector to put file position right */
@@ -467,6 +469,8 @@
                 if ( rc < 0 ) {
                     DEBUGF("fat_seek() failed\n");
                     errno = EIO;
+                    file->fileoffset += nread;
+                    file->cacheoffset = -1;
                     return nread ? nread : rc * 10 - 6;
                 }
             }
@@ -478,6 +482,8 @@
             if (rc < 1 ) {
                 DEBUGF("Failed caching sector\n");
                 errno = EIO;
+                file->fileoffset += nread;
+                file->cacheoffset = -1;
                 return nread ? nread : rc * 10 - 7;
             }
             memcpy( buf + nread, file->cache, count );




<Prev in Thread] Current Thread [Next in Thread>