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

@ -693,6 +693,8 @@ ErrorOr<void> VirtualFileSystem::symlink(StringView target, StringView linkpath,
auto inode = TRY(parent_inode.create_child(basename, S_IFLNK | 0644, 0, current_process.euid(), current_process.egid()));
auto target_buffer = UserOrKernelBuffer::for_kernel_buffer(const_cast<u8*>((u8 const*)target.characters_without_null_termination()));
MutexLocker locker(inode->m_inode_lock);
TRY(inode->prepare_to_write_data());
TRY(inode->write_bytes(0, target.length(), target_buffer, nullptr));
return {};
}