diff --git a/Userland/Libraries/LibPartition/EBRPartitionTable.cpp b/Userland/Libraries/LibPartition/EBRPartitionTable.cpp index ee2220d2d09..3335a1516d6 100644 --- a/Userland/Libraries/LibPartition/EBRPartitionTable.cpp +++ b/Userland/Libraries/LibPartition/EBRPartitionTable.cpp @@ -8,9 +8,15 @@ namespace Partition { +#ifdef KERNEL ErrorOr> EBRPartitionTable::try_to_initialize(Kernel::StorageDevice const& device) { auto table = TRY(adopt_nonnull_own_or_enomem(new (nothrow) EBRPartitionTable(device))); +#else +ErrorOr> EBRPartitionTable::try_to_initialize(NonnullRefPtr device_file) +{ + auto table = TRY(adopt_nonnull_own_or_enomem(new (nothrow) EBRPartitionTable(move(device_file)))); +#endif if (table->is_protective_mbr()) return Error::from_errno(ENOTSUP); if (!table->is_valid()) @@ -18,7 +24,11 @@ ErrorOr> EBRPartitionTable::try_to_initialize(K return table; } +#ifdef KERNEL void EBRPartitionTable::search_extended_partition(Kernel::StorageDevice const& device, MBRPartitionTable& checked_ebr, u64 current_block_offset, size_t limit) +#else +void EBRPartitionTable::search_extended_partition(NonnullRefPtr device, MBRPartitionTable& checked_ebr, u64 current_block_offset, size_t limit) +#endif { if (limit == 0) return; @@ -38,7 +48,11 @@ void EBRPartitionTable::search_extended_partition(Kernel::StorageDevice const& d search_extended_partition(device, *next_ebr, current_block_offset, (limit - 1)); } +#ifdef KERNEL EBRPartitionTable::EBRPartitionTable(Kernel::StorageDevice const& device) +#else +EBRPartitionTable::EBRPartitionTable(NonnullRefPtr device) +#endif : MBRPartitionTable(device) { if (!is_header_valid()) diff --git a/Userland/Libraries/LibPartition/EBRPartitionTable.h b/Userland/Libraries/LibPartition/EBRPartitionTable.h index d44f5a4490c..0e381293a3c 100644 --- a/Userland/Libraries/LibPartition/EBRPartitionTable.h +++ b/Userland/Libraries/LibPartition/EBRPartitionTable.h @@ -15,12 +15,25 @@ class EBRPartitionTable : public MBRPartitionTable { public: ~EBRPartitionTable(); +#ifdef KERNEL static ErrorOr> try_to_initialize(Kernel::StorageDevice const&); explicit EBRPartitionTable(Kernel::StorageDevice const&); - virtual bool is_valid() const override { return m_valid; }; +#else + static ErrorOr> try_to_initialize(NonnullRefPtr); + explicit EBRPartitionTable(NonnullRefPtr); +#endif + + virtual bool is_valid() const override + { + return m_valid; + } private: +#ifdef KERNEL void search_extended_partition(Kernel::StorageDevice const&, MBRPartitionTable&, u64, size_t limit); +#else + void search_extended_partition(NonnullRefPtr, MBRPartitionTable&, u64, size_t limit); +#endif bool m_valid { false }; };