1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-18 17:35:06 +00:00

Kernel/FileSystem: Make Inode::{write,read}_bytes methods non-virtual

We make these methods non-virtual because we want to ensure we properly
enforce locking of the m_inode_lock mutex. Also, for write operations,
we want to call prepare_to_write_data before the actual write. The
previous design required us to ensure the callers do that at various
places which lead to hard-to-find bugs. By moving everything to a place
where we call prepare_to_write_data only once, we eliminate a possibilty
of forgeting to call it on some code path in the kernel.
This commit is contained in:
Liav A 2022-08-06 04:22:20 +03:00 committed by Idan Horowitz
parent 4f4717e351
commit c88cc8557f
20 changed files with 87 additions and 72 deletions

View file

@ -398,9 +398,9 @@ u32 ISO9660FS::calculate_directory_entry_cache_key(ISO::DirectoryRecordHeader co
return LittleEndian { record.extent_location.little };
}
ErrorOr<size_t> ISO9660Inode::read_bytes(off_t offset, size_t size, UserOrKernelBuffer& buffer, OpenFileDescription*) const
ErrorOr<size_t> ISO9660Inode::read_bytes_locked(off_t offset, size_t size, UserOrKernelBuffer& buffer, OpenFileDescription*) const
{
MutexLocker inode_locker(m_inode_lock);
VERIFY(m_inode_lock.is_locked());
u32 data_length = LittleEndian { m_record.data_length.little };
u32 extent_location = LittleEndian { m_record.extent_location.little };
@ -493,7 +493,7 @@ ErrorOr<void> ISO9660Inode::flush_metadata()
return {};
}
ErrorOr<size_t> ISO9660Inode::write_bytes(off_t, size_t, UserOrKernelBuffer const&, OpenFileDescription*)
ErrorOr<size_t> ISO9660Inode::write_bytes_locked(off_t, size_t, UserOrKernelBuffer const&, OpenFileDescription*)
{
return EROFS;
}