From 9d0d78a64363721a72f37b30303a4006b1d532e5 Mon Sep 17 00:00:00 2001 From: Uwe Seimet <48174652+uweseimet@users.noreply.github.com> Date: Sun, 6 Feb 2022 20:44:28 +0100 Subject: [PATCH] Flush the cache on STOP UNIT (#644) --- src/raspberrypi/devices/disk.cpp | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/src/raspberrypi/devices/disk.cpp b/src/raspberrypi/devices/disk.cpp index ac3de0eb..d540ffc4 100644 --- a/src/raspberrypi/devices/disk.cpp +++ b/src/raspberrypi/devices/disk.cpp @@ -1293,16 +1293,21 @@ bool Disk::StartStop(const DWORD *cdb) SetStopped(!start); } - // Look at the eject bit and eject if necessary - if (load && !start) { - if (IsLocked()) { - // Cannot be ejected because it is locked - SetStatusCode(STATUS_PREVENT); - return false; - } + if (!start) { + // Flush the cache when stopping + disk.dcache->Save(); - // Eject - return Eject(false); + // Look at the eject bit and eject if necessary + if (load) { + if (IsLocked()) { + // Cannot be ejected because it is locked + SetStatusCode(STATUS_PREVENT); + return false; + } + + // Eject + return Eject(false); + } } return true;