mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-31 15:42:44 +00:00 
			
		
		
		
	 1102089f9f
			
		
	
	
		1102089f9f
		
	
	
	
	
		
			
			In the near future, we will be able to figure out connections between storage devices and their partitions, so there's no need to hardcode 16 partitions per storage device - each storage device should be able to have "infinite" count of partitions in it, and we should be able to use and figure out about them.
		
			
				
	
	
		
			41 lines
		
	
	
	
		
			1.2 KiB
		
	
	
	
		
			C++
		
	
	
	
	
	
			
		
		
	
	
			41 lines
		
	
	
	
		
			1.2 KiB
		
	
	
	
		
			C++
		
	
	
	
	
	
| /*
 | |
|  * Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
 | |
|  *
 | |
|  * SPDX-License-Identifier: BSD-2-Clause
 | |
|  */
 | |
| 
 | |
| #pragma once
 | |
| 
 | |
| #include <AK/RefPtr.h>
 | |
| #include <AK/WeakPtr.h>
 | |
| #include <Kernel/Devices/BlockDevice.h>
 | |
| #include <LibPartition/DiskPartitionMetadata.h>
 | |
| 
 | |
| namespace Kernel {
 | |
| 
 | |
| class DiskPartition final : public BlockDevice {
 | |
|     friend class DeviceManagement;
 | |
| 
 | |
| public:
 | |
|     static NonnullRefPtr<DiskPartition> create(BlockDevice&, MinorNumber, Partition::DiskPartitionMetadata);
 | |
|     virtual ~DiskPartition();
 | |
| 
 | |
|     virtual void start_request(AsyncBlockDeviceRequest&) override;
 | |
| 
 | |
|     // ^BlockDevice
 | |
|     virtual ErrorOr<size_t> read(OpenFileDescription&, u64, UserOrKernelBuffer&, size_t) override;
 | |
|     virtual bool can_read(OpenFileDescription const&, u64) const override;
 | |
|     virtual ErrorOr<size_t> write(OpenFileDescription&, u64, UserOrKernelBuffer const&, size_t) override;
 | |
|     virtual bool can_write(OpenFileDescription const&, u64) const override;
 | |
| 
 | |
|     Partition::DiskPartitionMetadata const& metadata() const;
 | |
| 
 | |
| private:
 | |
|     DiskPartition(BlockDevice&, MinorNumber, Partition::DiskPartitionMetadata);
 | |
|     virtual StringView class_name() const override;
 | |
| 
 | |
|     WeakPtr<BlockDevice> m_device;
 | |
|     Partition::DiskPartitionMetadata m_metadata;
 | |
| };
 | |
| 
 | |
| }
 |