mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-21 20:15:17 +00:00
Kernel+LibPartition: Move EBRPartitionTable into LibPartition
This commit is contained in:
parent
1a6ef03e4a
commit
9053d86b82
Notes:
sideshowbarker
2024-07-17 08:41:34 +09:00
Author: https://github.com/SamuelBowman Commit: https://github.com/SerenityOS/serenity/commit/9053d86b82 Pull-request: https://github.com/SerenityOS/serenity/pull/14432 Reviewed-by: https://github.com/linusg
6 changed files with 37 additions and 42 deletions
|
@ -104,7 +104,6 @@ set(KERNEL_SOURCES
|
|||
Storage/ATA/ATAPIDiscDevice.cpp
|
||||
Storage/ATA/ATAPort.cpp
|
||||
Storage/Partition/DiskPartition.cpp
|
||||
Storage/Partition/EBRPartitionTable.cpp
|
||||
Storage/Partition/GUIDPartitionTable.cpp
|
||||
Storage/NVMe/NVMeController.cpp
|
||||
Storage/NVMe/NVMeNameSpace.cpp
|
||||
|
@ -404,6 +403,7 @@ set(CRYPTO_SOURCES
|
|||
|
||||
set(PARTITION_SOURCES
|
||||
../Userland/Libraries/LibPartition/DiskPartitionMetadata.cpp
|
||||
../Userland/Libraries/LibPartition/EBRPartitionTable.cpp
|
||||
../Userland/Libraries/LibPartition/MBRPartitionTable.cpp
|
||||
../Userland/Libraries/LibPartition/PartitionTable.cpp
|
||||
)
|
||||
|
|
|
@ -1,33 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2020-2022, Liav A. <liavalb@hotmail.co.il>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <AK/Error.h>
|
||||
#include <AK/NonnullOwnPtr.h>
|
||||
#include <AK/RefPtr.h>
|
||||
#include <AK/Result.h>
|
||||
#include <AK/Vector.h>
|
||||
#include <Kernel/Storage/Partition/DiskPartition.h>
|
||||
#include <LibPartition/MBRPartitionTable.h>
|
||||
|
||||
namespace Kernel {
|
||||
|
||||
struct EBRPartitionHeader;
|
||||
class EBRPartitionTable : public Partition::MBRPartitionTable {
|
||||
public:
|
||||
~EBRPartitionTable();
|
||||
|
||||
static ErrorOr<NonnullOwnPtr<EBRPartitionTable>> try_to_initialize(StorageDevice const&);
|
||||
explicit EBRPartitionTable(StorageDevice const&);
|
||||
virtual bool is_valid() const override { return m_valid; };
|
||||
|
||||
private:
|
||||
void search_extended_partition(StorageDevice const&, MBRPartitionTable&, u64, size_t limit);
|
||||
|
||||
bool m_valid { false };
|
||||
};
|
||||
}
|
|
@ -21,10 +21,10 @@
|
|||
#include <Kernel/Storage/ATA/GenericIDE/ISAController.h>
|
||||
#include <Kernel/Storage/ATA/GenericIDE/PCIController.h>
|
||||
#include <Kernel/Storage/NVMe/NVMeController.h>
|
||||
#include <Kernel/Storage/Partition/EBRPartitionTable.h>
|
||||
#include <Kernel/Storage/Partition/GUIDPartitionTable.h>
|
||||
#include <Kernel/Storage/Ramdisk/Controller.h>
|
||||
#include <Kernel/Storage/StorageManagement.h>
|
||||
#include <LibPartition/EBRPartitionTable.h>
|
||||
#include <LibPartition/MBRPartitionTable.h>
|
||||
|
||||
namespace Kernel {
|
||||
|
@ -136,7 +136,7 @@ UNMAP_AFTER_INIT ErrorOr<NonnullOwnPtr<Partition::PartitionTable>> StorageManage
|
|||
auto mbr_table_or_error = Partition::MBRPartitionTable::try_to_initialize(device);
|
||||
if (!mbr_table_or_error.is_error())
|
||||
return mbr_table_or_error.release_value();
|
||||
auto ebr_table_or_error = EBRPartitionTable::try_to_initialize(device);
|
||||
auto ebr_table_or_error = Partition::EBRPartitionTable::try_to_initialize(device);
|
||||
if (!ebr_table_or_error.is_error()) {
|
||||
return ebr_table_or_error.release_value();
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
set(SOURCES
|
||||
DiskPartitionMetadata.cpp
|
||||
EBRPartitionTable.cpp
|
||||
MBRPartitionTable.cpp
|
||||
PartitionTable.cpp
|
||||
)
|
||||
|
|
|
@ -4,12 +4,11 @@
|
|||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include <AK/ByteBuffer.h>
|
||||
#include <Kernel/Storage/Partition/EBRPartitionTable.h>
|
||||
#include <LibPartition/EBRPartitionTable.h>
|
||||
|
||||
namespace Kernel {
|
||||
namespace Partition {
|
||||
|
||||
ErrorOr<NonnullOwnPtr<EBRPartitionTable>> EBRPartitionTable::try_to_initialize(StorageDevice const& device)
|
||||
ErrorOr<NonnullOwnPtr<EBRPartitionTable>> EBRPartitionTable::try_to_initialize(Kernel::StorageDevice const& device)
|
||||
{
|
||||
auto table = TRY(adopt_nonnull_own_or_enomem(new (nothrow) EBRPartitionTable(device)));
|
||||
if (table->is_protective_mbr())
|
||||
|
@ -19,7 +18,7 @@ ErrorOr<NonnullOwnPtr<EBRPartitionTable>> EBRPartitionTable::try_to_initialize(S
|
|||
return table;
|
||||
}
|
||||
|
||||
void EBRPartitionTable::search_extended_partition(StorageDevice const& device, MBRPartitionTable& checked_ebr, u64 current_block_offset, size_t limit)
|
||||
void EBRPartitionTable::search_extended_partition(Kernel::StorageDevice const& device, MBRPartitionTable& checked_ebr, u64 current_block_offset, size_t limit)
|
||||
{
|
||||
if (limit == 0)
|
||||
return;
|
||||
|
@ -39,7 +38,7 @@ void EBRPartitionTable::search_extended_partition(StorageDevice const& device, M
|
|||
search_extended_partition(device, *next_ebr, current_block_offset, (limit - 1));
|
||||
}
|
||||
|
||||
EBRPartitionTable::EBRPartitionTable(StorageDevice const& device)
|
||||
EBRPartitionTable::EBRPartitionTable(Kernel::StorageDevice const& device)
|
||||
: MBRPartitionTable(device)
|
||||
{
|
||||
if (!is_header_valid())
|
28
Userland/Libraries/LibPartition/EBRPartitionTable.h
Normal file
28
Userland/Libraries/LibPartition/EBRPartitionTable.h
Normal file
|
@ -0,0 +1,28 @@
|
|||
/*
|
||||
* 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 EBRPartitionHeader;
|
||||
class EBRPartitionTable : public MBRPartitionTable {
|
||||
public:
|
||||
~EBRPartitionTable();
|
||||
|
||||
static ErrorOr<NonnullOwnPtr<EBRPartitionTable>> try_to_initialize(Kernel::StorageDevice const&);
|
||||
explicit EBRPartitionTable(Kernel::StorageDevice const&);
|
||||
virtual bool is_valid() const override { return m_valid; };
|
||||
|
||||
private:
|
||||
void search_extended_partition(Kernel::StorageDevice const&, MBRPartitionTable&, u64, size_t limit);
|
||||
|
||||
bool m_valid { false };
|
||||
};
|
||||
|
||||
}
|
Loading…
Add table
Reference in a new issue