func (t *Target) handleVPD(s *Session, m, resp *packet.Message) { lun := int(m.LUN) alloc := int(packet.ParseUint(m.CDB[3:5])) vpd, err := t.LUNs[lun].VitalProductData(m.CDB[2]) if err != nil { resp.Status = 0x02 resp.SCSIResponse = 0x01 return } resp.RawData = vpd if len(vpd) >= alloc { resp.RawData = resp.RawData[:alloc] } }
func setError(resp *packet.Message, serr SCSIError) { buf := &bytes.Buffer{} data := serr.Bytes() buf.Write(packet.MarshalUint64(uint64(len(data)))[6:]) buf.Write(data) resp.RawData = buf.Bytes() }