mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 03:07:36 +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:
parent
53dd04e219
commit
b63a1dda63
13 changed files with 23 additions and 14 deletions
|
@ -284,8 +284,9 @@ ErrorOr<void> Plan9FSInode::chown(UserID, GroupID)
|
|||
return ENOTIMPL;
|
||||
}
|
||||
|
||||
ErrorOr<void> Plan9FSInode::truncate(u64 new_size)
|
||||
ErrorOr<void> Plan9FSInode::truncate_locked(u64 new_size)
|
||||
{
|
||||
VERIFY(m_inode_lock.is_locked());
|
||||
if (fs().m_remote_protocol_version >= Plan9FS::ProtocolVersion::v9P2000L) {
|
||||
Plan9FSMessage message { fs(), Plan9FSMessage::Type::Tsetattr };
|
||||
SetAttrMask valid = SetAttrMask::Size;
|
||||
|
|
|
@ -33,7 +33,7 @@ public:
|
|||
virtual ErrorOr<void> replace_child(StringView name, Inode& child) override;
|
||||
virtual ErrorOr<void> chmod(mode_t) override;
|
||||
virtual ErrorOr<void> chown(UserID, GroupID) override;
|
||||
virtual ErrorOr<void> truncate(u64) override;
|
||||
virtual ErrorOr<void> truncate_locked(u64) override;
|
||||
|
||||
private:
|
||||
// ^Inode
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue