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

Method ModeSense6

cpp/devices/disk.cpp:272–309  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

270}
271
272int Disk::ModeSense6(cdb_t cdb, vector<uint8_t>& buf) const
273{
274 // Get length, clear buffer
275 const auto length = static_cast<int>(min(buf.size(), static_cast<size_t>(cdb[4])));
276 fill_n(buf.begin(), length, 0);
277
278 // DEVICE SPECIFIC PARAMETER
279 if (IsProtected()) {
280 buf[2] = 0x80;
281 }
282
283 // Basic information
284 int size = 4;
285
286 // Add block descriptor if DBD is 0
287 if ((cdb[1] & 0x08) == 0) {
288 // Mode parameter header, block descriptor length
289 buf[3] = 0x08;
290
291 // Only if ready
292 if (IsReady()) {
293 // Short LBA mode parameter block descriptor (number of blocks and block length)
294 uint64_t disk_blocks = GetBlockCount();
295 if (disk_blocks > 0xFFFFFFFF)
296 disk_blocks = 0xFFFFFFFF;
297 SetInt32(buf, 4, static_cast<uint32_t>(disk_blocks));
298 SetInt32(buf, 8, GetSectorSizeInBytes());
299 }
300
301 size = 12;
302 }
303
304 size = AddModePages(cdb, buf, size, length, 255);
305
306 buf[0] = (uint8_t)size;
307
308 return size;
309}
310
311int Disk::ModeSense10(cdb_t cdb, vector<uint8_t>& buf) const
312{

Callers

nothing calls this directly

Calls 1

SetInt32Function · 0.85

Tested by

no test coverage detected