Kernel/FileSystem: Funnel calls to Inode::prepare_to_write_data method

Instead of requiring each FileSystem implementation to call this method
when trying to write data, do the calls at 2 points to avoid further
calls (or lack of them due to not remembering to use it) at other files
and locations in the codebase.
This commit is contained in:
Liav A 2022-07-27 21:42:16 +03:00 committed by Linus Groh
parent 38bf7863d0
commit fcc0e4d538
Notes: sideshowbarker 2024-07-17 20:22:04 +09:00
6 changed files with 12 additions and 11 deletions

View file

@ -937,15 +937,12 @@ ErrorOr<void> Ext2FSInode::resize(u64 new_size)
ErrorOr<size_t> Ext2FSInode::write_bytes(off_t offset, size_t count, UserOrKernelBuffer const& data, OpenFileDescription* description)
{
VERIFY(m_inode_lock.is_locked());
VERIFY(offset >= 0);
if (count == 0)
return 0;
MutexLocker inode_locker(m_inode_lock);
TRY(prepare_to_write_data());
if (is_symlink()) {
VERIFY(offset == 0);
if (max((size_t)(offset + count), (size_t)m_raw_inode.i_size) < max_inline_symlink_length) {