From 21f00d577df649cbac48826164434fc615a24efd Mon Sep 17 00:00:00 2001 From: Baptiste Wicht Date: Mon, 8 Aug 2016 21:02:03 +0200 Subject: [PATCH] Update blocks when written --- kernel/src/ata.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/kernel/src/ata.cpp b/kernel/src/ata.cpp index 4acca096..1537fa24 100644 --- a/kernel/src/ata.cpp +++ b/kernel/src/ata.cpp @@ -486,6 +486,12 @@ size_t ata::write_sectors(drive_descriptor& drive, uint64_t start, uint8_t count auto buffer = reinterpret_cast(const_cast(source)); for(size_t i = 0; i < count; ++i){ + // If the block is in cache, simply update the cache and write through the disk + auto block = cache.block_if_present((drive.controller << 8) + drive.drive, start + i); + if(block){ + std::copy_n(block, buffer, BLOCK_SIZE); + } + if(!read_write_sector(drive, start + i, buffer, false)){ return std::ERROR_FAILED; }