diff --git a/kernel/src/fs/StorageCache.cpp b/kernel/src/fs/StorageCache.cpp index 9d1bb404..a8614662 100644 --- a/kernel/src/fs/StorageCache.cpp +++ b/kernel/src/fs/StorageCache.cpp @@ -33,7 +33,7 @@ void StorageCache::clear() m_mutex.unlock(); } -StorageCache::StorageCache() +StorageCache::StorageCache(BlockDevice* device) : m_device(device) { g_storage_caches.append(this); } diff --git a/kernel/src/fs/StorageCache.h b/kernel/src/fs/StorageCache.h index d46df29e..2e302d60 100644 --- a/kernel/src/fs/StorageCache.h +++ b/kernel/src/fs/StorageCache.h @@ -4,12 +4,15 @@ #include #include +class BlockDevice; + class StorageCache : public LinkedListNode { public: struct CacheEntry { Buffer buffer {}; + bool dirty; }; void lock() @@ -28,10 +31,11 @@ class StorageCache : public LinkedListNode static void clear_caches(); - StorageCache(); + StorageCache(BlockDevice* device); ~StorageCache(); private: HashMap m_cache_entries; + BlockDevice* m_device; Mutex m_mutex; }; diff --git a/kernel/src/fs/devices/BlockDevice.cpp b/kernel/src/fs/devices/BlockDevice.cpp index 112b65b5..c8c9cc67 100644 --- a/kernel/src/fs/devices/BlockDevice.cpp +++ b/kernel/src/fs/devices/BlockDevice.cpp @@ -2,7 +2,8 @@ #include "arch/MMU.h" #include -BlockDevice::BlockDevice(u64 block_size, u64 num_blocks) : m_cache(), m_block_size(block_size), m_num_blocks(num_blocks) +BlockDevice::BlockDevice(u64 block_size, u64 num_blocks) + : m_cache(this), m_block_size(block_size), m_num_blocks(num_blocks) { }