diff --git a/pkg/scsi/backingstore.go b/pkg/scsi/backingstore.go index 6747ad8..1d9f8fc 100644 --- a/pkg/scsi/backingstore.go +++ b/pkg/scsi/backingstore.go @@ -34,7 +34,7 @@ type BackingStore interface { type BackingStoreFunc func() (BackingStore, error) -var registeredPlugins = map[name](BackingStoreFunc){} +var registeredPlugins = map[string](BackingStoreFunc){} func RegisterBackingStore(name string, f BackingStoreFunc) { registeredPlugins[name] = f diff --git a/pkg/scsi/drivers.go b/pkg/scsi/drivers.go index a8808b6..595d674 100644 --- a/pkg/scsi/drivers.go +++ b/pkg/scsi/drivers.go @@ -17,7 +17,7 @@ limitations under the License. // Target Driver Interface package scsi -var SCSITargetDriverState int +type SCSITargetDriverState int const ( // just registered @@ -51,7 +51,9 @@ type SCSITargetDriverOps interface { CommandNotify(nid uint64, result int, cmd *SCSICommand) error } -var fakeSCSITargetDriver SCSITargetDriver +type fakeSCSITargetDriver struct { + SCSITargetDriver +} func (fake *fakeSCSITargetDriver) Init() error { return nil diff --git a/pkg/scsi/error.go b/pkg/scsi/error.go index 357f9c9..a2b10af 100644 --- a/pkg/scsi/error.go +++ b/pkg/scsi/error.go @@ -63,7 +63,6 @@ var ( ASC_LOGICAL_UNIT_NOT_CONFIG SCSISubError = 0x3e00 /* Key 3: Medium Errors */ - ASC_WRITE_ERROR SCSISubError = 0x0c00 ASC_UNRECOVERED_READ SCSISubError = 0x1100 ASC_RECORDED_ENTITY_NOT_FOUND SCSISubError = 0x1400 ASC_UNKNOWN_FORMAT SCSISubError = 0x3001 diff --git a/pkg/scsi/sbc.go b/pkg/scsi/sbc.go index 4b7a199..3e75230 100644 --- a/pkg/scsi/sbc.go +++ b/pkg/scsi/sbc.go @@ -39,8 +39,8 @@ func (sbc *SBCSCSIDeviceProtocol) OfflineLu(lu *SCSILu) error { func NewSBCDevice() (SBCSCSIDeviceProtocol, error) { var sbc = SBCSCSIDeviceProtocol{ - Type: TYPE_DISK, - SCSIDeviceOps: make([]SCSIDeviceOperation, 0xff), + BaseSCSIDeviceProtocol{Type: TYPE_DISK, + SCSIDeviceOps: make([]SCSIDeviceOperation, 256)}, } for i := 0; i <= 256; i++ { sbc.SCSIDeviceOps = append(sbc.SCSIDeviceOps, NewSCSIDeviceOperation(SPCIllegalOp, nil, 0)) @@ -94,6 +94,8 @@ func NewSBCDevice() (SBCSCSIDeviceProtocol, error) { sbc.SCSIDeviceOps[WRITE_12] = NewSCSIDeviceOperation(SBCReadWrite, nil, PR_WE_FA|PR_EA_FA|PR_WE_FA|PR_WE_FN) sbc.SCSIDeviceOps[WRITE_VERIFY_12] = NewSCSIDeviceOperation(SBCReadWrite, nil, PR_EA_FA|PR_EA_FN) sbc.SCSIDeviceOps[VERIFY_12] = NewSCSIDeviceOperation(SBCVerify, nil, PR_EA_FA|PR_EA_FN) + + return sbc, nil } func SBCModeSelect(host int, cmd *SCSICommand) error { diff --git a/pkg/scsi/spc.go b/pkg/scsi/spc.go index 0e4c8c8..9504bc2 100644 --- a/pkg/scsi/spc.go +++ b/pkg/scsi/spc.go @@ -30,18 +30,17 @@ package scsi * 7 Automation/Drive Interface (ADT) * 8 AT Attachment Interface (ATA/ATAPI-7) */ -type ProtocolIdentifier int -var ( - PIV_FCP ProtocolIdentifier = iota - PIV_SPI ProtocolIdentifier - PIV_S3P ProtocolIdentifier - PIV_SBP ProtocolIdentifier - PIV_SRP ProtocolIdentifier - PIV_ISCSI ProtocolIdentifier - PIV_SAS ProtocolIdentifier - PIV_ADT ProtocolIdentifier - PIV_ATA ProtocolIdentifier +const ( + PIV_FCP = iota + PIV_SPI + PIV_S3P + PIV_SBP + PIV_SRP + PIV_ISCSI + PIV_SAS + PIV_ADT + PIV_ATA ) /* @@ -88,18 +87,17 @@ var ( * 7 - MD5 logical unit identifier - 7.6.3.10 * 8 - SCSI name string - 7.6.3.11 */ -type DesignatorType int -var ( - DESG_VENDOR DesignatorType = iota - DESG_T10 DesignatorType - DESG_EUI64 DesignatorType - DESG_NAA DesignatorType - DESG_REL_TGT_PORT DesignatorType - DESG_TGT_PORT_GRP DesignatorType - DESG_LU_GRP DesignatorType - DESG_MD5 DesignatorType - DESG_SCSI DesignatorType +const ( + DESG_VENDOR = iota + DESG_T10 + DESG_EUI64 + DESG_NAA + DESG_REL_TGT_PORT + DESG_TGT_PORT_GRP + DESG_LU_GRP + DESG_MD5 + DESG_SCSI ) func SPCIllegalOp(host int, cmd *SCSICommand) error { @@ -175,4 +173,5 @@ func SPCRequestSense(host int, cmd *SCSICommand) error { } func SPCSendDiagnostics(host int, cmd *SCSICommand) error { + return nil } diff --git a/pkg/scsi/target.go b/pkg/scsi/target.go index e167c77..30267c0 100644 --- a/pkg/scsi/target.go +++ b/pkg/scsi/target.go @@ -16,13 +16,22 @@ limitations under the License. package scsi -var SCSITargetState int +type SCSITargetState int var ( TargetOnline SCSITargetState = 1 TargetReady SCSITargetState = 2 ) +const ( + PR_SPECIAL = (1 << 5) + PR_WE_FA = (1 << 4) + PR_EA_FA = (1 << 3) + PR_RR_FR = (1 << 2) + PR_WE_FN = (1 << 1) + PR_EA_FN = (1 << 0) +) + type SCSITarget struct { Name string TID int