Skip to content

Commit

Permalink
resize cache after change of sector size
Browse files Browse the repository at this point in the history
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 <kkaempf@gmail.com>
  • Loading branch information
kkaempf committed Jan 7, 2024
1 parent cfab99c commit a467046
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 1 deletion.
2 changes: 1 addition & 1 deletion cpp/devices/disk.h
Original file line number Diff line number Diff line change
Expand Up @@ -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, vector<byte>>&, int, bool) const override;
void AddErrorPage(map<int, vector<byte>>&, bool) const;
virtual void AddFormatPage(map<int, vector<byte>>&, bool) const;
Expand Down
1 change: 1 addition & 0 deletions cpp/devices/disk_cache.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<uint8_t>, uint32_t); // Sector Read
Expand Down
2 changes: 2 additions & 0 deletions cpp/devices/scsicd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,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);
Expand Down

0 comments on commit a467046

Please sign in to comment.