[freenos] [freenos commit] r183 - Ext2File correction for r181 and before: respect inode->size.

  • From: codesite-noreply@xxxxxxxxxx
  • To: freenos@xxxxxxxxxxxxx
  • Date: Fri, 03 Jul 2009 11:28:46 +0000

Author: nieklinnenbank
Date: Fri Jul  3 03:41:09 2009
New Revision: 183

Modified:
   trunk/srv/filesystem/ext2/Ext2File.cpp

Log:
Ext2File correction for r181 and before: respect inode->size.
It seemed the previous patch was wrong, which this patch will
hopefully fix. Additionally the copyOffset variable is now computed
faster and simpler.


Modified: trunk/srv/filesystem/ext2/Ext2File.cpp
==============================================================================
--- trunk/srv/filesystem/ext2/Ext2File.cpp      (original)
+++ trunk/srv/filesystem/ext2/Ext2File.cpp      Fri Jul  3 03:41:09 2009
@@ -42,13 +42,12 @@
     {
        blockNr++;
     }
-    /* We don't have __umoddi3 yet. Calculate modulus manually. */
-    while (copyOffset >= EXT2_BLOCK_SIZE(sb))
-    {
-       copyOffset -= EXT2_BLOCK_SIZE(sb);
-    }
+    /* Adjust the copy offset within this block. */
+    copyOffset -= EXT2_BLOCK_SIZE(sb) * blockNr;
+
     /* Loop all blocks. */
-    for (; blockNr < inode->blocks - 1 && total < msg->size; blockNr++)
+    for (; blockNr < inode->blocks - 1 && total < msg->size &&
+          inode->size - (msg->offset + total); blockNr++)
     {
        /* Calculate the offset in storage for this block. */
        storageOffset = ext2->getOffset(inode, blockNr);
@@ -64,9 +63,9 @@
        bytes = EXT2_BLOCK_SIZE(sb) - copyOffset;
        
        /* Respect the inode size. */
-       if (bytes > inode->size - copyOffset)
+       if (bytes > inode->size - (msg->offset + total))
        {
-           bytes = inode->size - copyOffset;
+           bytes = inode->size - (msg->offset + total);
        }
        /* Respect the remote process buffer. */
        if (bytes > msg->size - total)

Other related posts:

  • » [freenos] [freenos commit] r183 - Ext2File correction for r181 and before: respect inode->size. - codesite-noreply