mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-31 03:52:43 +00:00 
			
		
		
		
	 3af70cb0fc
			
		
	
	
		3af70cb0fc
		
	
	
	
	
		
			
			It is starting to get a little messy with how each device can try to add or remove itself to either /sys/dev/block or /sys/dev/char directories. To better do this, we introduce 4 virtual methods to take care of that, so until we ensure all nodes in /sys/dev/block and /sys/dev/char are actual symlinks, we allow the Device base class to call virtual methods upon insertion or before being destroying, so it add itself elegantly to either of these directories or remove itself when needed. For special cases where we need to create symlinks, we have two virtual methods to be called otherwise to do almost the same thing mentioned before, but to use symlinks instead.
		
			
				
	
	
		
			30 lines
		
	
	
	
		
			837 B
		
	
	
	
		
			C++
		
	
	
	
	
	
			
		
		
	
	
			30 lines
		
	
	
	
		
			837 B
		
	
	
	
		
			C++
		
	
	
	
	
	
| /*
 | |
|  * Copyright (c) 2022, Liav A. <liavalb@hotmail.co.il>
 | |
|  *
 | |
|  * SPDX-License-Identifier: BSD-2-Clause
 | |
|  */
 | |
| 
 | |
| #pragma once
 | |
| 
 | |
| #include <Kernel/FileSystem/SysFS/Component.h>
 | |
| #include <Kernel/FileSystem/SysFS/Subsystems/DeviceIdentifiers/DeviceComponent.h>
 | |
| #include <Kernel/FileSystem/SysFS/Subsystems/DeviceIdentifiers/Directory.h>
 | |
| 
 | |
| namespace Kernel {
 | |
| 
 | |
| class BlockDevice;
 | |
| class SysFSBlockDevicesDirectory final : public SysFSDirectory {
 | |
| 
 | |
| public:
 | |
|     virtual StringView name() const override { return "block"sv; }
 | |
|     static NonnullRefPtr<SysFSBlockDevicesDirectory> must_create(SysFSDeviceIdentifiersDirectory const&);
 | |
| 
 | |
|     static SysFSBlockDevicesDirectory& the();
 | |
| 
 | |
|     ChildList& devices_list(Badge<BlockDevice>) { return m_child_components; }
 | |
| 
 | |
| private:
 | |
|     explicit SysFSBlockDevicesDirectory(SysFSDeviceIdentifiersDirectory const&);
 | |
| };
 | |
| 
 | |
| }
 |