2020-12-25 22:48:29 +02:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2020, Liav A. <liavalb@hotmail.co.il>
|
|
|
|
*
|
2021-04-22 01:24:48 -07:00
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
2020-12-25 22:48:29 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2020-12-31 13:17:03 +02:00
|
|
|
#include <AK/UUID.h>
|
2020-12-25 22:48:29 +02:00
|
|
|
|
2022-02-12 14:21:28 -05:00
|
|
|
namespace Partition {
|
2020-12-25 22:48:29 +02:00
|
|
|
|
|
|
|
class DiskPartitionMetadata {
|
2020-12-31 13:17:03 +02:00
|
|
|
private:
|
|
|
|
class PartitionType {
|
|
|
|
friend class DiskPartitionMetadata;
|
|
|
|
|
|
|
|
public:
|
|
|
|
explicit PartitionType(u8 partition_type);
|
|
|
|
explicit PartitionType(Array<u8, 16> partition_type);
|
|
|
|
UUID to_uuid() const;
|
|
|
|
u8 to_byte_indicator() const;
|
|
|
|
bool is_uuid() const;
|
|
|
|
bool is_valid() const;
|
|
|
|
|
|
|
|
private:
|
|
|
|
Array<u8, 16> m_partition_type {};
|
|
|
|
bool m_partition_type_is_uuid { false };
|
|
|
|
};
|
|
|
|
|
2020-12-25 22:48:29 +02:00
|
|
|
public:
|
2020-12-31 13:17:03 +02:00
|
|
|
DiskPartitionMetadata(u64 block_offset, u64 block_limit, u8 partition_type);
|
|
|
|
DiskPartitionMetadata(u64 start_block, u64 end_block, Array<u8, 16> partition_type);
|
2021-10-02 16:39:33 -07:00
|
|
|
DiskPartitionMetadata(u64 block_offset, u64 block_limit, Array<u8, 16> partition_type, UUID unique_guid, u64 special_attributes);
|
2020-12-25 22:48:29 +02:00
|
|
|
u64 start_block() const;
|
|
|
|
u64 end_block() const;
|
|
|
|
|
2020-12-26 16:53:30 +02:00
|
|
|
DiskPartitionMetadata offset(u64 blocks_count) const;
|
|
|
|
|
2020-12-25 22:48:29 +02:00
|
|
|
Optional<u64> special_attributes() const;
|
2022-04-01 20:58:27 +03:00
|
|
|
PartitionType const& type() const;
|
2020-12-31 13:17:03 +02:00
|
|
|
const UUID& unique_guid() const;
|
2020-12-25 22:48:29 +02:00
|
|
|
|
|
|
|
private:
|
|
|
|
u64 m_start_block;
|
|
|
|
u64 m_end_block;
|
2020-12-31 13:17:03 +02:00
|
|
|
PartitionType m_type;
|
|
|
|
UUID m_unique_guid {};
|
2020-12-26 16:53:30 +02:00
|
|
|
u64 m_attributes { 0 };
|
2020-12-25 22:48:29 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|