1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-25 22:15:06 +00:00
serenity/Userland/Libraries/LibPartition/PartitionTable.h
Liav A 500b7b08d6 Kernel: Move the Storage directory to be a new directory under Devices
The Storage subsystem, like the Audio and HID subsystems, exposes Unix
device files (for example, in the /dev directory). To ensure consistency
across the repository, we should make the Storage subsystem to reside in
the Kernel/Devices directory like the two other mentioned subsystems.
2023-06-02 11:04:37 +02:00

43 lines
1 KiB
C++

/*
* Copyright (c) 2020-2022, Liav A. <liavalb@hotmail.co.il>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <AK/NonnullRefPtr.h>
#include <LibPartition/DiskPartitionMetadata.h>
#ifdef KERNEL
# include <Kernel/Devices/Storage/StorageDevice.h>
#else
# include <LibCore/Forward.h>
#endif
namespace Partition {
class PartitionTable {
public:
Optional<DiskPartitionMetadata> partition(unsigned index) const;
size_t partitions_count() const { return m_partitions.size(); }
virtual ~PartitionTable() = default;
virtual bool is_valid() const = 0;
Vector<DiskPartitionMetadata> partitions() const { return m_partitions; }
size_t block_size() const { return m_block_size; }
protected:
#ifdef KERNEL
explicit PartitionTable(Kernel::StorageDevice&);
NonnullRefPtr<Kernel::StorageDevice> m_device;
#else
explicit PartitionTable(NonnullRefPtr<Core::DeprecatedFile>);
NonnullRefPtr<Core::DeprecatedFile> m_device_file;
#endif
Vector<DiskPartitionMetadata> m_partitions;
size_t m_block_size;
};
}