mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 11:28:12 +00:00
BlockDevice -> DiskDevice.
BlockDevice was the wrong name for this abstraction, since a block device is a type of file in a unix system, and we should use that name for that concept in the fs implementation.
This commit is contained in:
parent
72bb80a9ae
commit
9cd0a34b5c
12 changed files with 62 additions and 64 deletions
32
VirtualFileSystem/FileBackedDiskDevice.h
Normal file
32
VirtualFileSystem/FileBackedDiskDevice.h
Normal file
|
@ -0,0 +1,32 @@
|
|||
#pragma once
|
||||
|
||||
#include "DiskDevice.h"
|
||||
#include <AK/RetainPtr.h>
|
||||
#include <AK/String.h>
|
||||
#include <AK/Types.h>
|
||||
#include <stdio.h>
|
||||
|
||||
class FileBackedDiskDevice final : public DiskDevice {
|
||||
public:
|
||||
static RetainPtr<FileBackedDiskDevice> create(String&& imagePath, unsigned blockSize);
|
||||
virtual ~FileBackedDiskDevice() override;
|
||||
|
||||
bool isValid() const { return m_file; }
|
||||
|
||||
virtual unsigned blockSize() const override;
|
||||
virtual bool readBlock(unsigned index, byte* out) const override;
|
||||
virtual bool writeBlock(unsigned index, const byte*) override;
|
||||
virtual bool read(qword offset, unsigned length, byte* out) const override;
|
||||
virtual bool write(qword offset, unsigned length, const byte* data) override;
|
||||
|
||||
private:
|
||||
virtual const char* className() const override;
|
||||
|
||||
FileBackedDiskDevice(String&& imagePath, unsigned blockSize);
|
||||
|
||||
String m_imagePath;
|
||||
FILE* m_file { nullptr };
|
||||
qword m_fileLength { 0 };
|
||||
unsigned m_blockSize { 0 };
|
||||
};
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue