resize cache after change of sector size

The disk cache is based on sector size and must be resized when the
sector size changes.

Disk::ResizeCache needs a `raw` parameter, make this value accessible
from the current cache.

Signed-off-by: Klaus Kämpf <kkaempf@gmail.com>
This commit is contained in:
Klaus Kämpf 2024-01-06 22:29:28 +01:00
parent 2d86000329
commit 55769d557d
3 changed files with 4 additions and 1 deletions

View File

@ -112,7 +112,7 @@ protected:
void SetUpCache(off_t, bool = false);
void ResizeCache(const string&, bool);
bool GetRawMode() { return (cache?cache->GetRawMode():false); }
void SetUpModePages(map<int, vector<byte>>&, int, bool) const override;
void AddErrorPage(map<int, vector<byte>>&, bool) const;
virtual void AddFormatPage(map<int, vector<byte>>&, bool) const;

View File

@ -51,6 +51,7 @@ public:
~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<uint8_t>, uint32_t); // Sector Read

View File

@ -178,6 +178,8 @@ void SCSICD::ModeSelect(scsi_command cmd, cdb_t cdb, span<const uint8_t> 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);