2019-06-02 11:58:59 +03:00
|
|
|
#pragma once
|
|
|
|
|
2019-06-21 19:45:35 +03:00
|
|
|
#include <AK/RefPtr.h>
|
2019-06-02 11:58:59 +03:00
|
|
|
#include <Kernel/Devices/DiskDevice.h>
|
|
|
|
|
2019-06-02 12:38:37 +03:00
|
|
|
class DiskPartition final : public DiskDevice {
|
2019-06-02 11:58:59 +03:00
|
|
|
public:
|
2019-10-07 03:12:37 +03:00
|
|
|
static NonnullRefPtr<DiskPartition> create(DiskDevice&, unsigned block_offset, unsigned block_limit);
|
2019-06-02 12:38:37 +03:00
|
|
|
virtual ~DiskPartition();
|
2019-06-02 11:58:59 +03:00
|
|
|
|
2019-07-03 22:17:35 +03:00
|
|
|
virtual bool read_block(unsigned index, u8* out) const override;
|
|
|
|
virtual bool write_block(unsigned index, const u8*) override;
|
|
|
|
virtual bool read_blocks(unsigned index, u16 count, u8*) override;
|
|
|
|
virtual bool write_blocks(unsigned index, u16 count, const u8*) override;
|
2019-06-02 11:58:59 +03:00
|
|
|
|
2019-08-02 16:18:47 +03:00
|
|
|
// ^BlockDevice
|
|
|
|
virtual ssize_t read(FileDescription&, u8*, ssize_t) override { return 0; }
|
|
|
|
virtual bool can_read(FileDescription&) const override { return true; }
|
|
|
|
virtual ssize_t write(FileDescription&, const u8*, ssize_t) override { return 0; }
|
|
|
|
virtual bool can_write(FileDescription&) const override { return true; }
|
|
|
|
|
2019-06-02 11:58:59 +03:00
|
|
|
private:
|
|
|
|
virtual const char* class_name() const override;
|
|
|
|
|
2019-10-07 03:12:37 +03:00
|
|
|
DiskPartition(DiskDevice&, unsigned block_offset, unsigned block_limit);
|
2019-06-02 11:58:59 +03:00
|
|
|
|
2019-06-21 19:37:47 +03:00
|
|
|
NonnullRefPtr<DiskDevice> m_device;
|
2019-06-02 12:29:17 +03:00
|
|
|
unsigned m_block_offset;
|
2019-10-07 03:12:37 +03:00
|
|
|
unsigned m_block_limit;
|
2019-06-02 11:58:59 +03:00
|
|
|
};
|