2020-01-18 09:38:21 +01:00
|
|
|
/*
|
2022-04-25 19:54:06 +03:00
|
|
|
* Copyright (c) 2020-2022, 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
|
|
|
|
|
|
2022-03-01 19:42:06 -05:00
|
|
|
#include <LibPartition/MBRPartitionTable.h>
|
2019-10-07 03:12:37 +03:00
|
|
|
|
2022-03-01 20:21:35 -05:00
|
|
|
namespace Partition {
|
2020-02-16 01:27:42 +01:00
|
|
|
|
2020-12-26 16:53:30 +02:00
|
|
|
struct GUIDPartitionHeader;
|
2022-03-01 20:21:35 -05:00
|
|
|
class GUIDPartitionTable final : public MBRPartitionTable {
|
2019-10-07 03:12:37 +03:00
|
|
|
public:
|
2021-02-28 14:42:08 +01:00
|
|
|
virtual ~GUIDPartitionTable() = default;
|
2019-10-07 03:12:37 +03:00
|
|
|
|
2022-06-15 22:57:05 -04:00
|
|
|
#ifdef KERNEL
|
2023-02-19 23:36:30 +01:00
|
|
|
static ErrorOr<NonnullOwnPtr<GUIDPartitionTable>> try_to_initialize(Kernel::StorageDevice&);
|
|
|
|
|
explicit GUIDPartitionTable(Kernel::StorageDevice&);
|
2022-06-15 22:57:05 -04:00
|
|
|
#else
|
2023-02-08 21:08:01 +01:00
|
|
|
static ErrorOr<NonnullOwnPtr<GUIDPartitionTable>> try_to_initialize(NonnullRefPtr<Core::DeprecatedFile>);
|
|
|
|
|
explicit GUIDPartitionTable(NonnullRefPtr<Core::DeprecatedFile>);
|
2022-06-15 22:57:05 -04:00
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
virtual bool is_valid() const override
|
|
|
|
|
{
|
|
|
|
|
return m_valid;
|
|
|
|
|
}
|
2019-10-07 03:12:37 +03:00
|
|
|
|
2020-12-26 16:53:30 +02:00
|
|
|
private:
|
2020-12-31 13:17:03 +02:00
|
|
|
bool is_unused_entry(Array<u8, 16>) const;
|
2022-04-01 20:58:27 +03:00
|
|
|
GUIDPartitionHeader const& header() const;
|
2020-12-26 16:53:30 +02:00
|
|
|
bool initialize();
|
2019-10-07 03:12:37 +03:00
|
|
|
|
2020-12-26 16:53:30 +02:00
|
|
|
bool m_valid { true };
|
|
|
|
|
ByteBuffer m_cached_header;
|
2019-10-07 03:12:37 +03:00
|
|
|
};
|
2020-02-16 01:27:42 +01:00
|
|
|
|
|
|
|
|
}
|