mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-30 18:52:44 +00:00 
			
		
		
		
	 3d6b838df3
			
		
	
	
		3d6b838df3
		
	
	
	
	
		
			
			The implemented cloning mechanism should be sound: - If a PartitionTable is passed a File with ShouldCloseFileDescriptor::Yes, then it will keep it alive until the PartitionTable is destroyed. - If a PartitionTable is passed a File with ShouldCloseFileDescriptor::No, then the caller has to ensure that the file descriptor remains alive. If the caller is EBRPartitionTable, the same consideration holds. If the caller is PartitionEditor::PartitionModel, this is satisfied by keeping an OwnPtr<Core::File> around which is the originally opened file. Therefore, we never leak any fds, and never access a Core::File or fd after destroying it.
		
			
				
	
	
		
			32 lines
		
	
	
	
		
			818 B
		
	
	
	
		
			C++
		
	
	
	
	
	
			
		
		
	
	
			32 lines
		
	
	
	
		
			818 B
		
	
	
	
		
			C++
		
	
	
	
	
	
| /*
 | |
|  * Copyright (c) 2020-2022, Liav A. <liavalb@hotmail.co.il>
 | |
|  *
 | |
|  * SPDX-License-Identifier: BSD-2-Clause
 | |
|  */
 | |
| 
 | |
| #pragma once
 | |
| 
 | |
| #include <AK/NonnullRefPtr.h>
 | |
| #include <LibPartition/DiskPartitionMetadata.h>
 | |
| #include <LibPartition/PartitionableDevice.h>
 | |
| 
 | |
| namespace Partition {
 | |
| 
 | |
| class PartitionTable {
 | |
| public:
 | |
|     Optional<DiskPartitionMetadata> partition(unsigned index) const;
 | |
|     size_t partitions_count() const { return m_partitions.size(); }
 | |
|     virtual ~PartitionTable() = default;
 | |
|     virtual bool is_valid() const = 0;
 | |
| 
 | |
|     Vector<DiskPartitionMetadata> partitions() const { return m_partitions; }
 | |
|     size_t block_size() const { return m_device.block_size(); }
 | |
| 
 | |
| protected:
 | |
|     explicit PartitionTable(PartitionableDevice&&);
 | |
|     PartitionableDevice m_device;
 | |
| 
 | |
|     Vector<DiskPartitionMetadata> m_partitions;
 | |
| };
 | |
| 
 | |
| }
 |