mirror of
https://github.com/RGBCube/serenity
synced 2025-05-25 19:25:07 +00:00
Kernel: Convert read_block method to get a reference instead of pointer
BlockBasedFileSystem::read_block method should get a reference of a UserOrKernelBuffer. If we need to force caching a block, we will call other method to do so.
This commit is contained in:
parent
d1366b660e
commit
092a13211a
3 changed files with 80 additions and 47 deletions
|
@ -27,10 +27,22 @@
|
|||
#pragma once
|
||||
|
||||
#include <Kernel/FileSystem/FileBackedFileSystem.h>
|
||||
#include <Kernel/KResult.h>
|
||||
|
||||
namespace Kernel {
|
||||
|
||||
class DiskCache;
|
||||
class BlockBasedFS : public FileBackedFS {
|
||||
friend class DiskCache;
|
||||
|
||||
private:
|
||||
struct CacheEntry {
|
||||
IntrusiveListNode list_node;
|
||||
u32 block_index { 0 };
|
||||
u8* data { nullptr };
|
||||
bool has_data { false };
|
||||
};
|
||||
|
||||
public:
|
||||
virtual ~BlockBasedFS() override;
|
||||
|
||||
|
@ -42,7 +54,10 @@ public:
|
|||
protected:
|
||||
explicit BlockBasedFS(FileDescription&);
|
||||
|
||||
int read_block(unsigned index, UserOrKernelBuffer* buffer, size_t count, size_t offset = 0, bool allow_cache = true) const;
|
||||
int read_block(unsigned index, UserOrKernelBuffer& buffer, size_t count, size_t offset = 0, bool allow_cache = true) const;
|
||||
bool force_cache_block(unsigned index) const;
|
||||
KResultOr<CacheEntry> cache_block(unsigned index) const;
|
||||
|
||||
int read_blocks(unsigned index, unsigned count, UserOrKernelBuffer& buffer, bool allow_cache = true) const;
|
||||
|
||||
bool raw_read(unsigned index, UserOrKernelBuffer& buffer);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue