mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 15:40:19 +00:00
Ext2FS: Clear out the direct block list when an inode is resized to 0
e2fsck was complaining about blocks being allocated in an inode's list of direct blocks while at the same time being free in the block bitmap. It was easy to reproduce by creating a file with non-zero length and then truncating it. This fixes the issue by clearing out the direct block list when resizing a file to 0.
This commit is contained in:
parent
dd43cf2657
commit
df758a5a51
Notes:
sideshowbarker
2024-07-19 01:18:13 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/df758a5a516
1 changed files with 7 additions and 0 deletions
|
@ -227,6 +227,13 @@ bool Ext2FS::write_block_list_for_inode(InodeIndex inode_index, ext2_inode& e2in
|
|||
{
|
||||
LOCKER(m_lock);
|
||||
|
||||
if (blocks.is_empty()) {
|
||||
e2inode.i_blocks = 0;
|
||||
memset(e2inode.i_block, 0, sizeof(e2inode.i_block));
|
||||
write_ext2_inode(inode_index, e2inode);
|
||||
return true;
|
||||
}
|
||||
|
||||
// NOTE: There is a mismatch between i_blocks and blocks.size() since i_blocks includes meta blocks and blocks.size() does not.
|
||||
auto old_block_count = ceil_div(static_cast<size_t>(e2inode.i_size), block_size());
|
||||
|
||||
|
|
Loading…
Reference in a new issue