MCPcopy Create free account
hub / github.com/PiSCSI/piscsi / RequestSense

Method RequestSense

cpp/devices/primary_device.cpp:140–166  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

138}
139
140void PrimaryDevice::RequestSense()
141{
142 int lun = GetController()->GetEffectiveLun();
143
144 // Note: According to the SCSI specs the LUN handling for REQUEST SENSE non-existing LUNs do *not* result
145 // in CHECK CONDITION. Only the Sense Key and ASC are set in order to signal the non-existing LUN.
146 if (!GetController()->HasDeviceForLun(lun)) {
147 // LUN 0 can be assumed to be present (required to call RequestSense() below)
148 assert(GetController()->HasDeviceForLun(0));
149
150 lun = 0;
151
152 // Do not raise an exception here because the rest of the code must be executed
153 GetController()->Error(sense_key::illegal_request, asc::invalid_lun);
154
155 GetController()->SetStatus(status::good);
156 }
157
158 vector<byte> buf = GetController()->GetDeviceForLun(lun)->HandleRequestSense();
159
160 const size_t allocation_length = min(buf.size(), static_cast<size_t>(GetController()->GetCmdByte(4)));
161
162 memcpy(GetController()->GetBuffer().data(), buf.data(), allocation_length);
163 GetController()->SetLength(static_cast<uint32_t>(allocation_length));
164
165 EnterDataInPhase();
166}
167
168void PrimaryDevice::SendDiagnostic()
169{

Callers

nothing calls this directly

Calls 8

GetEffectiveLunMethod · 0.80
HasDeviceForLunMethod · 0.80
SetStatusMethod · 0.80
HandleRequestSenseMethod · 0.80
GetDeviceForLunMethod · 0.80
GetCmdByteMethod · 0.80
SetLengthMethod · 0.80
ErrorMethod · 0.45

Tested by

no test coverage detected