forked from Bananymous/banan-os
Kernel: remove message from BAN::Error
We don't store the error message anymore in BAN::Error. Instead we store a error code that can be mapped into a string. This allows BAN::Error to only take 4 bytes instead of 128. We should also make some kernel initialization just panic instead of returning errors since they are required for succesfull boot anyway.
This commit is contained in:
@@ -463,7 +463,7 @@ namespace Kernel
|
||||
}
|
||||
|
||||
if (m_superblock.magic != 0xEF53)
|
||||
return BAN::Error::from_c_string("Not an ext2 filesystem");
|
||||
return BAN::Error::from_error_code(ErrorCode::Ext2_Invalid);
|
||||
|
||||
if (m_superblock.rev_level < 1)
|
||||
{
|
||||
@@ -475,7 +475,7 @@ namespace Kernel
|
||||
uint32_t number_of_block_groups = BAN::Math::div_round_up(superblock().inodes_count, superblock().inodes_per_group);
|
||||
uint32_t number_of_block_groups_check = BAN::Math::div_round_up(superblock().blocks_count, superblock().blocks_per_group);
|
||||
if (number_of_block_groups != number_of_block_groups_check)
|
||||
return BAN::Error::from_c_string("Ambiguous number of block groups");
|
||||
return BAN::Error::from_error_code(ErrorCode::Ext2_Corrupted);
|
||||
|
||||
ASSERT(!(m_superblock.feature_incompat & Ext2::Enum::FEATURE_INCOMPAT_COMPRESSION));
|
||||
//ASSERT(!(m_superblock.feature_incompat & Ext2::Enum::FEATURE_INCOMPAT_FILETYPE));
|
||||
@@ -546,7 +546,7 @@ namespace Kernel
|
||||
}
|
||||
}
|
||||
|
||||
return BAN::Error::from_c_string("No free inodes available in the whole filesystem");
|
||||
return BAN::Error::from_error_code(ErrorCode::Ext2_NoInodes);
|
||||
}
|
||||
|
||||
void Ext2FS::read_block(uint32_t block, BAN::Span<uint8_t> buffer)
|
||||
|
||||
@@ -18,8 +18,7 @@ namespace Kernel
|
||||
return BAN::Error::from_errno(ENOMEM);
|
||||
BAN::ScopeGuard guard([] { delete s_instance; s_instance = nullptr; } );
|
||||
|
||||
if (root.size() < 5 || root.substring(0, 5) != "/dev/")
|
||||
return BAN::Error::from_c_string("root must be in /dev/");
|
||||
ASSERT(root.size() >= 5 && root.substring(0, 5) == "/dev/"sv);;
|
||||
root = root.substring(5);
|
||||
|
||||
auto partition_inode = TRY(DeviceManager::get().read_directory_inode(root));
|
||||
@@ -43,11 +42,11 @@ namespace Kernel
|
||||
{
|
||||
auto partition_file = TRY(file_from_absolute_path(partition));
|
||||
if (partition_file.inode->inode_type() != Inode::InodeType::Device)
|
||||
return BAN::Error::from_c_string("Not a partition");
|
||||
return BAN::Error::from_errno(ENOTBLK);
|
||||
|
||||
Device* device = (Device*)partition_file.inode.ptr();
|
||||
if (device->device_type() != Device::DeviceType::Partition)
|
||||
return BAN::Error::from_c_string("Not a partition");
|
||||
if (device->device_type() != Device::DeviceType::BlockDevice)
|
||||
return BAN::Error::from_errno(ENOTBLK);
|
||||
|
||||
auto* file_system = TRY(Ext2FS::create(*(Partition*)device));
|
||||
return mount(file_system, target);
|
||||
@@ -90,8 +89,7 @@ namespace Kernel
|
||||
ASSERT(path.front() == '/');
|
||||
|
||||
auto inode = root_inode();
|
||||
if (!inode)
|
||||
return BAN::Error::from_c_string("No root inode available");
|
||||
ASSERT(inode);
|
||||
|
||||
BAN::String canonical_path;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user