Kernel: Fix TmpFS for 32 bit target

There was a problem when sizeof(size_t) != sizeof(PageInfo)
This commit is contained in:
Bananymous 2025-07-18 19:06:37 +03:00
parent 11ae220dbe
commit 5874fd640e
2 changed files with 8 additions and 5 deletions

View File

@ -28,7 +28,7 @@ namespace Kernel
// 1x singly indirect // 1x singly indirect
// 1x doubly indirect // 1x doubly indirect
// 1x triply indirect // 1x triply indirect
BAN::Array<paddr_t, 5> block; BAN::Array<size_t, 5> block;
static constexpr size_t direct_block_count = 2; static constexpr size_t direct_block_count = 2;
#elif ARCH(i686) #elif ARCH(i686)
uint32_t __padding; uint32_t __padding;
@ -36,8 +36,8 @@ namespace Kernel
// 1x singly indirect // 1x singly indirect
// 1x doubly indirect // 1x doubly indirect
// 1x triply indirect // 1x triply indirect
BAN::Array<paddr_t, 8> block; BAN::Array<size_t, 16> block;
static constexpr size_t direct_block_count = 5; static constexpr size_t direct_block_count = 13;
#else #else
#error #error
#endif #endif

View File

@ -284,7 +284,9 @@ namespace Kernel
paddr_t page_to_free; paddr_t page_to_free;
PageTable::with_fast_page(layer1_page.paddr(), [&] { PageTable::with_fast_page(layer1_page.paddr(), [&] {
auto& allocated_pages = PageTable::fast_page_as_sized<size_t>(page_infos_per_page - 1); static_assert(sizeof(size_t) <= sizeof(PageInfo));
auto& allocated_pages = PageTable::fast_page_as<size_t>(PAGE_SIZE - sizeof(size_t));
ASSERT(allocated_pages > 0); ASSERT(allocated_pages > 0);
allocated_pages--; allocated_pages--;
@ -405,8 +407,9 @@ namespace Kernel
PageTable::with_fast_page(layer1_page.paddr(), [&] { PageTable::with_fast_page(layer1_page.paddr(), [&] {
constexpr size_t pages_per_block = page_infos_per_page - 1; constexpr size_t pages_per_block = page_infos_per_page - 1;
static_assert(sizeof(size_t) <= sizeof(PageInfo));
auto& allocated_pages = PageTable::fast_page_as_sized<size_t>(pages_per_block); auto& allocated_pages = PageTable::fast_page_as<size_t>(PAGE_SIZE - sizeof(size_t));
if (allocated_pages == pages_per_block) if (allocated_pages == pages_per_block)
return; return;