From a467046fc9a04a7dcb4754a4a89dba5d59544778 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Klaus=20K=C3=A4mpf?= Date: Sat, 6 Jan 2024 22:29:28 +0100 Subject: [PATCH] resize cache after change of sector size MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The disk cache is based on sector size and must be resized when the sector size changes. However, Disk::ResizeCache needs a 'raw' parameter which is not accessible. So we need to add GetRawMode to DiskCache. Signed-off-by: Klaus Kämpf --- cpp/devices/disk.h | 2 +- cpp/devices/disk_cache.h | 1 + cpp/devices/scsicd.cpp | 2 ++ 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/cpp/devices/disk.h b/cpp/devices/disk.h index 7364ad085b..4d4e45584f 100644 --- a/cpp/devices/disk.h +++ b/cpp/devices/disk.h @@ -111,7 +111,7 @@ class Disk : public StorageDevice, private ScsiBlockCommands void SetUpCache(off_t, bool = false); void ResizeCache(const string&, bool); - + bool GetRawMode() { return cache->GetRawMode(); } void SetUpModePages(map>&, int, bool) const override; void AddErrorPage(map>&, bool) const; virtual void AddFormatPage(map>&, bool) const; diff --git a/cpp/devices/disk_cache.h b/cpp/devices/disk_cache.h index ec486edd85..b1f299c509 100644 --- a/cpp/devices/disk_cache.h +++ b/cpp/devices/disk_cache.h @@ -51,6 +51,7 @@ class DiskCache ~DiskCache() = default; void SetRawMode(bool b) { cd_raw = b; } // CD-ROM raw mode setting + bool GetRawMode() { return cd_raw; } bool Save(); // Save and release all bool ReadSector(span, uint32_t); // Sector Read diff --git a/cpp/devices/scsicd.cpp b/cpp/devices/scsicd.cpp index 7aa529c30e..57e94398af 100644 --- a/cpp/devices/scsicd.cpp +++ b/cpp/devices/scsicd.cpp @@ -181,6 +181,8 @@ void SCSICD::ModeSelect(scsi_command cmd, cdb_t cdb, span buf, in SetSectorSizeInBytes(wanted_sector_size); ClearTrack(); CreateDataTrack(); + FlushCache(); + ResizeCache(GetFilename(), GetRawMode()); } if (const string result = scsi_command_util::ModeSelect(cmd, cdb, buf, length, sector_size);