mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 07:58:11 +00:00
Kernel: Use ErrorOr in BlockBased and Ext2 filesystem raw read and write
These functions used to return booleans which withheld useful error information for callers. Internally they would suppress and convert Error objects. We now log or propagate these errors up the stack.
This commit is contained in:
parent
df6b9cdb0c
commit
cf45370c47
5 changed files with 34 additions and 43 deletions
|
@ -234,10 +234,10 @@ ErrorOr<void> ISO9660FS::parse_volume_set()
|
|||
|
||||
auto current_block_index = first_data_area_block;
|
||||
while (true) {
|
||||
bool result = raw_read(BlockIndex { current_block_index }, block_buffer);
|
||||
if (!result) {
|
||||
dbgln_if(ISO9660_DEBUG, "Failed to read volume descriptor from ISO file");
|
||||
return EIO;
|
||||
auto result = raw_read(BlockIndex { current_block_index }, block_buffer);
|
||||
if (result.is_error()) {
|
||||
dbgln_if(ISO9660_DEBUG, "Failed to read volume descriptor from ISO file: {}", result.error());
|
||||
return result;
|
||||
}
|
||||
|
||||
auto const* header = reinterpret_cast<ISO::VolumeDescriptorHeader const*>(block->data());
|
||||
|
@ -387,11 +387,7 @@ ErrorOr<NonnullRefPtr<ISO9660FS::DirectoryEntry>> ISO9660FS::directory_entry_for
|
|||
|
||||
auto blocks = TRY(KBuffer::try_create_with_size(data_length, Memory::Region::Access::Read | Memory::Region::Access::Write, "ISO9660FS: Directory traversal buffer"));
|
||||
auto blocks_buffer = UserOrKernelBuffer::for_kernel_buffer(blocks->data());
|
||||
auto did_read = raw_read_blocks(BlockBasedFileSystem::BlockIndex { extent_location }, data_length / logical_block_size(), blocks_buffer);
|
||||
if (!did_read) {
|
||||
return EIO;
|
||||
}
|
||||
|
||||
TRY(raw_read_blocks(BlockBasedFileSystem::BlockIndex { extent_location }, data_length / logical_block_size(), blocks_buffer));
|
||||
auto entry = TRY(DirectoryEntry::try_create(extent_location, data_length, move(blocks)));
|
||||
m_directory_entry_cache.set(key, entry);
|
||||
|
||||
|
@ -428,10 +424,7 @@ ErrorOr<size_t> ISO9660Inode::read_bytes(off_t offset, size_t size, UserOrKernel
|
|||
auto buffer_offset = buffer.offset(nread);
|
||||
dbgln_if(ISO9660_VERY_DEBUG, "ISO9660Inode::read_bytes: Reading {} bytes into buffer offset {}/{}, logical block index: {}", bytes_to_read, nread, total_bytes, current_block_index.value());
|
||||
|
||||
if (bool result = const_cast<ISO9660FS&>(fs()).raw_read(current_block_index, block_buffer); !result) {
|
||||
return EIO;
|
||||
}
|
||||
|
||||
TRY(const_cast<ISO9660FS&>(fs()).raw_read(current_block_index, block_buffer));
|
||||
TRY(buffer_offset.write(block->data() + initial_offset, bytes_to_read));
|
||||
|
||||
nread += bytes_to_read;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue