mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-31 20:32:44 +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
				
			
		|  | @ -361,9 +361,9 @@ ErrorOr<void> RAMFSInode::remove_child(StringView name) | |||
|     return {}; | ||||
| } | ||||
| 
 | ||||
| ErrorOr<void> RAMFSInode::truncate(u64 size) | ||||
| ErrorOr<void> RAMFSInode::truncate_locked(u64 size) | ||||
| { | ||||
|     MutexLocker locker(m_inode_lock); | ||||
|     VERIFY(m_inode_lock.is_locked()); | ||||
|     VERIFY(!is_directory()); | ||||
| 
 | ||||
|     u64 block_index = size / DataBlock::block_size + ((size % DataBlock::block_size == 0) ? 0 : 1); | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Liav A
						Liav A