mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-01-24 10:12:25 -05:00
3d6b838df3
The implemented cloning mechanism should be sound: - If a PartitionTable is passed a File with ShouldCloseFileDescriptor::Yes, then it will keep it alive until the PartitionTable is destroyed. - If a PartitionTable is passed a File with ShouldCloseFileDescriptor::No, then the caller has to ensure that the file descriptor remains alive. If the caller is EBRPartitionTable, the same consideration holds. If the caller is PartitionEditor::PartitionModel, this is satisfied by keeping an OwnPtr<Core::File> around which is the originally opened file. Therefore, we never leak any fds, and never access a Core::File or fd after destroying it.
35 lines
757 B
C++
35 lines
757 B
C++
/*
|
|
* Copyright (c) 2020-2022, Liav A. <liavalb@hotmail.co.il>
|
|
*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <LibPartition/MBRPartitionTable.h>
|
|
|
|
namespace Partition {
|
|
|
|
struct GUIDPartitionHeader;
|
|
class GUIDPartitionTable final : public MBRPartitionTable {
|
|
public:
|
|
virtual ~GUIDPartitionTable() = default;
|
|
|
|
static ErrorOr<NonnullOwnPtr<GUIDPartitionTable>> try_to_initialize(PartitionableDevice);
|
|
explicit GUIDPartitionTable(PartitionableDevice);
|
|
|
|
virtual bool is_valid() const override
|
|
{
|
|
return m_valid;
|
|
}
|
|
|
|
private:
|
|
bool is_unused_entry(Array<u8, 16>) const;
|
|
GUIDPartitionHeader const& header() const;
|
|
bool initialize();
|
|
|
|
bool m_valid { true };
|
|
ByteBuffer m_cached_header;
|
|
};
|
|
|
|
}
|