From f3cf9af6bf5a033a9822d72db6482c6d9738b84a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Axel=20D=C3=B6rfler?= Date: Wed, 14 Apr 2010 14:36:02 +0000 Subject: [PATCH] * Fill the gap between a write and the former file size with zeros, too. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36263 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/add-ons/kernel/file_systems/bfs/Inode.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/add-ons/kernel/file_systems/bfs/Inode.cpp b/src/add-ons/kernel/file_systems/bfs/Inode.cpp index ca1f6b2c93..2972bc518a 100644 --- a/src/add-ons/kernel/file_systems/bfs/Inode.cpp +++ b/src/add-ons/kernel/file_systems/bfs/Inode.cpp @@ -1565,7 +1565,9 @@ Inode::WriteAt(Transaction& transaction, off_t pos, const uint8* buffer, writeLocker.Lock(); } - if (pos + length > Size()) { + off_t oldSize = Size(); + + if (pos + length > oldSize) { // let's grow the data stream to the size needed status_t status = SetFileSize(transaction, pos + length); if (status != B_OK) { @@ -1589,6 +1591,9 @@ Inode::WriteAt(Transaction& transaction, off_t pos, const uint8* buffer, writeLocker.Unlock(); + if (oldSize < pos) + FillGapWithZeros(oldSize, pos); + // If we don't want to write anything, we can now return (we may // just have changed the file size using the position parameter) if (length == 0)