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