summaryrefslogtreecommitdiff
path: root/Kernel/Storage/Partition/PartitionTable.h
blob: 34d955bd10e4cf65d836792c5147f94a8942c9ff (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
/*
 * Copyright (c) 2020, Liav A. <liavalb@hotmail.co.il>
 *
 * SPDX-License-Identifier: BSD-2-Clause
 */

#pragma once

#include <AK/RefPtr.h>
#include <AK/Vector.h>
#include <Kernel/Storage/Partition/DiskPartition.h>
#include <Kernel/Storage/Partition/DiskPartitionMetadata.h>
#include <Kernel/Storage/StorageDevice.h>

namespace Kernel {

class PartitionTable {
public:
    enum class Error {
        Invalid,
        MBRProtective,
        ContainsEBR,
    };

public:
    Optional<DiskPartitionMetadata> partition(unsigned index);
    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; }

protected:
    explicit PartitionTable(StorageDevice const&);

    NonnullRefPtr<StorageDevice> m_device;
    Vector<DiskPartitionMetadata> m_partitions;
};

}