Kernel: Make FileSystem::initialize() return KResult

This forced me to also come up with error codes for a bunch of
situations where we'd previously just panic the kernel.
This commit is contained in:
Andreas Kling 2021-08-14 14:02:47 +02:00
parent 46b93174fc
commit d30d776ca4
Notes: sideshowbarker 2024-07-18 06:57:23 +09:00
21 changed files with 61 additions and 58 deletions

View file

@ -114,26 +114,26 @@ BlockBasedFileSystem::~BlockBasedFileSystem()
{
}
bool BlockBasedFileSystem::initialize()
KResult BlockBasedFileSystem::initialize()
{
VERIFY(block_size() != 0);
auto cached_block_data = KBuffer::try_create_with_size(DiskCache::EntryCount * block_size());
if (!cached_block_data)
return false;
return ENOMEM;
auto entries_data = KBuffer::try_create_with_size(DiskCache::EntryCount * sizeof(CacheEntry));
if (!entries_data)
return false;
return ENOMEM;
auto disk_cache = adopt_own_if_nonnull(new (nothrow) DiskCache(*this, cached_block_data.release_nonnull(), entries_data.release_nonnull()));
if (!disk_cache)
return false;
return ENOMEM;
m_cache.with_exclusive([&](auto& cache) {
cache = move(disk_cache);
});
return true;
return KSuccess;
}
KResult BlockBasedFileSystem::write_block(BlockIndex index, const UserOrKernelBuffer& data, size_t count, size_t offset, bool allow_cache)