Skip to content

Commit

Permalink
Update block size change handling for tapes, according to SCSI-2 specs
Browse files Browse the repository at this point in the history
  • Loading branch information
uweseimet committed Oct 26, 2024
1 parent c15d7f5 commit 7112254
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 2 deletions.
2 changes: 1 addition & 1 deletion cpp/devices/storage_device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ void StorageDevice::ModeSelect(cdb_t cdb, span<const uint8_t> buf, int length)
{
// PF
if (!(cdb[1] & 0x10)) {
// Vendor-specific parameters (SCSI-1) are not supported.
// Vendor-specific parameters (all parameters in SCSI-1 are vendor-specific) are not supported.
// Do not report an error in order to support Apple's HD SC Setup.
return;
}
Expand Down
2 changes: 1 addition & 1 deletion cpp/devices/storage_device.h
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ class StorageDevice : public PrimaryDevice

void ModeSelect(cdb_t, span<const uint8_t>, int) override;
pair<int, int> EvaluateBlockDescriptors(scsi_command, span<const uint8_t>, int) const;
int VerifyBlockSizeChange(int, bool) const;
virtual int VerifyBlockSizeChange(int, bool) const;
unordered_set<uint32_t> GetBlockSizes() const;
bool SetBlockSize(uint32_t);

Expand Down
6 changes: 6 additions & 0 deletions cpp/devices/tape.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,12 @@ vector<uint8_t> Tape::InquiryInternal() const
return HandleInquiry(device_type::sequential_access, true);
}

int Tape::VerifyBlockSizeChange(int requested_size, bool temporary) const
{
// Special handling of block size 0 for sequential-access devices, according to the SCSI-2 specification
return requested_size || !temporary ? VerifyBlockSizeChange(requested_size, temporary) : 0;
}

void Tape::SetUpModePages(map<int, vector<byte>> &pages, int page, bool changeable) const
{
StorageDevice::SetUpModePages(pages, page, changeable);
Expand Down
2 changes: 2 additions & 0 deletions cpp/devices/tape.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,8 @@ class Tape : public StorageDevice, public ScsiStreamCommands

uint32_t GetByteCount() const;

int VerifyBlockSizeChange(int, bool) const override;

void AddModeBlockDescriptor(map<int, vector<byte>>&) const;
void AddMediumPartitionPage(map<int, vector<byte>>&, bool) const;
void AddDataCompressionPage(map<int, vector<byte>>&) const;
Expand Down

0 comments on commit 7112254

Please sign in to comment.