update main #1

Merged
Sinipelto merged 240 commits from Bananymous/banan-os:main into main 2023-11-20 13:20:51 +02:00
1 changed files with 27 additions and 0 deletions
Showing only changes of commit 464737fbe9 - Show all commits

View File

@ -26,6 +26,12 @@ namespace Kernel
requires BAN::is_same_v<decltype(func(buffer)), void>;
};
template<typename F>
concept for_each_inode_callback = requires(F func, BAN::RefPtr<TmpInode> inode)
{
requires BAN::is_same_v<decltype(func(inode)), BAN::Iteration>;
};
}
@ -58,6 +64,9 @@ namespace Kernel
void free_block(size_t index);
BAN::ErrorOr<size_t> allocate_block();
template<TmpFuncs::for_each_inode_callback F>
void for_each_inode(F callback);
private:
struct PageInfo
{
@ -149,4 +158,22 @@ namespace Kernel
});
}
template<TmpFuncs::for_each_inode_callback F>
void TmpFileSystem::for_each_inode(F callback)
{
LockGuard _(m_lock);
for (auto& [_, inode] : m_inode_cache)
{
switch (callback(inode))
{
case BAN::Iteration::Continue:
break;
case BAN::Iteration::Break:
return;
default:
ASSERT_NOT_REACHED();
}
}
}
}