mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-06-02 16:33:13 +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:
parent
4f4717e351
commit
c88cc8557f
Notes:
sideshowbarker
2024-07-17 07:07:09 +09:00
Author: https://github.com/supercomputer7
Commit: c88cc8557f
Pull-request: https://github.com/SerenityOS/serenity/pull/14785
Reviewed-by: https://github.com/IdanHo ✅
20 changed files with 87 additions and 72 deletions
|
@ -106,6 +106,19 @@ void Inode::will_be_destroyed()
|
|||
(void)flush_metadata();
|
||||
}
|
||||
|
||||
ErrorOr<size_t> Inode::write_bytes(off_t offset, size_t length, UserOrKernelBuffer const& target_buffer, OpenFileDescription* open_description)
|
||||
{
|
||||
MutexLocker locker(m_inode_lock);
|
||||
TRY(prepare_to_write_data());
|
||||
return write_bytes_locked(offset, length, target_buffer, open_description);
|
||||
}
|
||||
|
||||
ErrorOr<size_t> Inode::read_bytes(off_t offset, size_t length, UserOrKernelBuffer& buffer, OpenFileDescription* open_description) const
|
||||
{
|
||||
MutexLocker locker(m_inode_lock, Mutex::Mode::Shared);
|
||||
return read_bytes_locked(offset, length, buffer, open_description);
|
||||
}
|
||||
|
||||
ErrorOr<void> Inode::update_timestamps([[maybe_unused]] Optional<time_t> atime, [[maybe_unused]] Optional<time_t> ctime, [[maybe_unused]] Optional<time_t> mtime)
|
||||
{
|
||||
return ENOTIMPL;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue