mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-31 09:52:44 +00:00 
			
		
		
		
	Kernel/DevFS: Add the ability to remove device nodes
In order to make this kind of operation simpler, we no longer use a Vector to store pointers to DevFSDeviceInode, but an IntrusiveList is used instead. Also, we only allow to remove device nodes for now, but in theory we can allow to remove all kinds of files from the DevFS.
This commit is contained in:
		
							parent
							
								
									f52d102270
								
							
						
					
					
						commit
						750ca2190b
					
				
					 2 changed files with 13 additions and 0 deletions
				
			
		|  | @ -194,6 +194,18 @@ KResultOr<NonnullRefPtr<Inode>> DevFSRootDirectoryInode::lookup(StringView name) | ||||||
|     } |     } | ||||||
|     return ENOENT; |     return ENOENT; | ||||||
| } | } | ||||||
|  | 
 | ||||||
|  | KResult DevFSRootDirectoryInode::remove_child(const StringView& name) | ||||||
|  | { | ||||||
|  |     MutexLocker locker(fs().m_lock); | ||||||
|  |     for (auto& node : m_nodes) { | ||||||
|  |         if (node.name() == name) { | ||||||
|  |             m_nodes.remove(node); | ||||||
|  |             return KSuccess; | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  |     return KResult(ENOENT); | ||||||
|  | } | ||||||
| KResultOr<NonnullRefPtr<Inode>> DevFSRootDirectoryInode::create_child(StringView name, mode_t mode, dev_t device_mode, UserID, GroupID) | KResultOr<NonnullRefPtr<Inode>> DevFSRootDirectoryInode::create_child(StringView name, mode_t mode, dev_t device_mode, UserID, GroupID) | ||||||
| { | { | ||||||
|     MutexLocker locker(fs().m_lock); |     MutexLocker locker(fs().m_lock); | ||||||
|  |  | ||||||
|  | @ -151,6 +151,7 @@ private: | ||||||
|     virtual KResult traverse_as_directory(Function<bool(FileSystem::DirectoryEntryView const&)>) const override; |     virtual KResult traverse_as_directory(Function<bool(FileSystem::DirectoryEntryView const&)>) const override; | ||||||
|     virtual KResultOr<NonnullRefPtr<Inode>> lookup(StringView name) override; |     virtual KResultOr<NonnullRefPtr<Inode>> lookup(StringView name) override; | ||||||
|     virtual InodeMetadata metadata() const override; |     virtual InodeMetadata metadata() const override; | ||||||
|  |     virtual KResult remove_child(const StringView& name) override; | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| } | } | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Liav A
						Liav A