mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-26 14:28:49 +00:00
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:
parent
38bf7863d0
commit
fcc0e4d538
Notes:
sideshowbarker
2024-07-17 20:22:04 +09:00
Author: https://github.com/supercomputer7
Commit: fcc0e4d538
Pull-request: https://github.com/SerenityOS/serenity/pull/14713
6 changed files with 12 additions and 11 deletions
|
@ -42,7 +42,12 @@ ErrorOr<size_t> InodeFile::write(OpenFileDescription& description, u64 offset, U
|
|||
if (Checked<off_t>::addition_would_overflow(offset, count))
|
||||
return EOVERFLOW;
|
||||
|
||||
auto nwritten = TRY(m_inode->write_bytes(offset, count, data, &description));
|
||||
size_t nwritten = 0;
|
||||
{
|
||||
MutexLocker locker(m_inode->m_inode_lock);
|
||||
TRY(m_inode->prepare_to_write_data());
|
||||
nwritten = TRY(m_inode->write_bytes(offset, count, data, &description));
|
||||
}
|
||||
if (nwritten > 0) {
|
||||
auto mtime_result = m_inode->set_mtime(kgettimeofday().to_truncated_seconds());
|
||||
Thread::current()->did_file_write(nwritten);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue