Kernel: Closing file backed mmap wont expand the file size

This commit is contained in:
Bananymous 2024-12-03 16:08:59 +02:00
parent 67e9ca56ac
commit e6a2f55a59
1 changed files with 2 additions and 1 deletions

View File

@ -81,7 +81,8 @@ namespace Kernel
memcpy(page_buffer, PageTable::fast_page_as_ptr(), PAGE_SIZE);
});
if (auto ret = inode->write(page_index * PAGE_SIZE, BAN::ConstByteSpan::from(page_buffer)); ret.is_error())
const size_t write_size = BAN::Math::min<size_t>(PAGE_SIZE, inode->size() - page_index * PAGE_SIZE);
if (auto ret = inode->write(page_index * PAGE_SIZE, BAN::ConstByteSpan::from(page_buffer).slice(0, write_size)); ret.is_error())
dwarnln("{}", ret.error());
}