mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-31 06:32:44 +00:00 
			
		
		
		
	Kernel: Use KBuffers for ProcFS and SynthFS
Instead of generating ByteBuffers and keeping those lying around, have these filesystems generate KBuffers instead. These are way less spooky to leave around for a while. Since FileDescription will keep a generated file buffer around until userspace has read the whole thing, this prevents trivially exhausting the kmalloc heap by opening many files in /proc for example. The code responsible for generating each /proc file is not perfectly efficient and many of them still use ByteBuffers internally but they at least go away when we return now. :^)
This commit is contained in:
		
							parent
							
								
									6b6b86fbf3
								
							
						
					
					
						commit
						79e22acb22
					
				
					 7 changed files with 58 additions and 43 deletions
				
			
		|  | @ -3,6 +3,7 @@ | |||
| #include <AK/HashMap.h> | ||||
| #include <Kernel/FileSystem/FileSystem.h> | ||||
| #include <Kernel/FileSystem/Inode.h> | ||||
| #include <Kernel/KBuffer.h> | ||||
| #include <Kernel/UnixTypes.h> | ||||
| 
 | ||||
| class SynthFSInode; | ||||
|  | @ -75,8 +76,8 @@ private: | |||
| 
 | ||||
|     String m_name; | ||||
|     InodeIdentifier m_parent; | ||||
|     ByteBuffer m_data; | ||||
|     Function<ByteBuffer(SynthFSInode&)> m_generator; | ||||
|     Optional<KBuffer> m_data; | ||||
|     Function<KBuffer(SynthFSInode&)> m_generator; | ||||
|     Function<ssize_t(SynthFSInode&, const ByteBuffer&)> m_write_callback; | ||||
|     Vector<SynthFSInode*> m_children; | ||||
|     InodeMetadata m_metadata; | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Andreas Kling
						Andreas Kling