2020-01-18 05:38:21 -03:00
|
|
|
/*
|
2020-12-26 11:53:30 -03:00
|
|
|
* Copyright (c) 2020, Liav A. <liavalb@hotmail.co.il>
|
2020-01-18 05:38:21 -03:00
|
|
|
*
|
2021-04-22 05:24:48 -03:00
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
2020-01-18 05:38:21 -03:00
|
|
|
*/
|
|
|
|
|
|
2019-10-06 21:12:37 -03:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
#include <AK/RefPtr.h>
|
|
|
|
|
#include <AK/Vector.h>
|
2020-12-25 15:23:35 -03:00
|
|
|
#include <Kernel/Storage/Partition/DiskPartition.h>
|
2020-12-26 11:53:30 -03:00
|
|
|
#include <Kernel/Storage/Partition/DiskPartitionMetadata.h>
|
|
|
|
|
#include <Kernel/Storage/StorageDevice.h>
|
2019-10-06 21:12:37 -03:00
|
|
|
|
2020-02-15 21:27:42 -03:00
|
|
|
namespace Kernel {
|
|
|
|
|
|
2020-12-26 11:53:30 -03:00
|
|
|
class PartitionTable {
|
2019-10-06 21:12:37 -03:00
|
|
|
public:
|
2020-12-26 11:53:30 -03:00
|
|
|
enum class Error {
|
|
|
|
|
Invalid,
|
|
|
|
|
MBRProtective,
|
|
|
|
|
ConatinsEBR,
|
|
|
|
|
};
|
2019-10-06 21:12:37 -03:00
|
|
|
|
2020-12-26 11:53:30 -03:00
|
|
|
public:
|
|
|
|
|
Optional<DiskPartitionMetadata> partition(unsigned index);
|
|
|
|
|
size_t partitions_count() const { return m_partitions.size(); }
|
2021-02-28 10:42:08 -03:00
|
|
|
virtual ~PartitionTable() = default;
|
2020-12-26 11:53:30 -03:00
|
|
|
virtual bool is_valid() const = 0;
|
2019-10-06 21:12:37 -03:00
|
|
|
|
2020-12-26 11:53:30 -03:00
|
|
|
Vector<DiskPartitionMetadata> partitions() const { return m_partitions; }
|
2019-10-06 21:12:37 -03:00
|
|
|
|
2020-12-26 11:53:30 -03:00
|
|
|
protected:
|
|
|
|
|
explicit PartitionTable(const StorageDevice&);
|
2019-10-06 21:12:37 -03:00
|
|
|
|
2020-12-26 11:53:30 -03:00
|
|
|
NonnullRefPtr<StorageDevice> m_device;
|
|
|
|
|
Vector<DiskPartitionMetadata> m_partitions;
|
2019-10-06 21:12:37 -03:00
|
|
|
};
|
2020-02-15 21:27:42 -03:00
|
|
|
|
|
|
|
|
}
|