mirror of
https://github.com/fergalmoran/ladybird.git
synced 2026-01-06 00:25:12 +00:00
Kernel/FileSystem: Enforce locking of m_inode_lock when truncating Inode
Such operation is almost equivalent to writing on an Inode, so lock the Inode m_inode_lock exclusively. All FileSystem Inode implementations then override a new method called truncate_locked which should implement the actual truncating.
This commit is contained in:
@@ -1071,9 +1071,9 @@ ErrorOr<void> Ext2FSInode::chown(UserID uid, GroupID gid)
|
||||
return {};
|
||||
}
|
||||
|
||||
ErrorOr<void> Ext2FSInode::truncate(u64 size)
|
||||
ErrorOr<void> Ext2FSInode::truncate_locked(u64 size)
|
||||
{
|
||||
MutexLocker locker(m_inode_lock);
|
||||
VERIFY(m_inode_lock.is_locked());
|
||||
if (static_cast<u64>(m_raw_inode.i_size) == size)
|
||||
return {};
|
||||
TRY(resize(size));
|
||||
|
||||
Reference in New Issue
Block a user