/* * Copyright (c) 2018-2020, Andreas Kling * * SPDX-License-Identifier: BSD-2-Clause */ #pragma once #include #include #include #include namespace Kernel { class DiskPartition final : public BlockDevice { friend class DeviceManagement; public: static NonnullRefPtr create(BlockDevice&, unsigned, DiskPartitionMetadata); virtual ~DiskPartition(); virtual void start_request(AsyncBlockDeviceRequest&) override; // ^BlockDevice virtual ErrorOr read(OpenFileDescription&, u64, UserOrKernelBuffer&, size_t) override; virtual bool can_read(const OpenFileDescription&, u64) const override; virtual ErrorOr write(OpenFileDescription&, u64, const UserOrKernelBuffer&, size_t) override; virtual bool can_write(const OpenFileDescription&, u64) const override; const DiskPartitionMetadata& metadata() const; private: DiskPartition(BlockDevice&, unsigned, DiskPartitionMetadata); virtual StringView class_name() const override; WeakPtr m_device; DiskPartitionMetadata m_metadata; }; }