Nice if an experienced problem matches a bug in the implementation that

closely: Inode::WriteAt() didn't call Inode::WriteBack() in case the
file size was enlarged - it was only written in case the file was closed
which a) could have not happened because of a crash, and b) would move
the change into the wrong transaction, and could therefore result in
an incorrect update, as seen.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@15094 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler 2005-11-23 18:52:17 +00:00
parent 2b028fcaa0
commit 7df07b24d3

View File

@ -1190,8 +1190,6 @@ Inode::ReadAt(off_t pos, uint8 *buffer, size_t *_length)
status_t
Inode::WriteAt(Transaction &transaction, off_t pos, const uint8 *buffer, size_t *_length)
{
// call the right WriteAt() method, depending on the inode flags
// update the last modification time in memory, it will be written
// back to the inode, and the index when the file is closed
// ToDo: should update the internal last modified time only at this point!
@ -1229,6 +1227,13 @@ Inode::WriteAt(Transaction &transaction, off_t pos, const uint8 *buffer, size_t
// have to fill the gap between that position and the old file
// size with zeros.
FillGapWithZeros(oldSize, pos);
// we need to write back the inode here because it has to
// go into this transaction (we cannot wait until the file
// is closed)
status = WriteBack(transaction);
if (status < B_OK)
return status;
}
// If we don't want to write anything, we can now return (we may
@ -1837,8 +1842,7 @@ Inode::SetFileSize(Transaction &transaction, off_t size)
// fails, so we should shrink the stream to its former size
ShrinkStream(transaction, oldSize);
}
}
else
} else
status = ShrinkStream(transaction, size);
if (status < B_OK)