diff --git a/cmd/version.go b/cmd/version.go index 3c3722d..52b9b79 100644 --- a/cmd/version.go +++ b/cmd/version.go @@ -14,7 +14,7 @@ func newVersionCommand(cli *client.Client) *cobra.Command { Short: "Print the version number of gotgt", Long: `All software has versions. This is Gotgt 's`, Run: func(cmd *cobra.Command, args []string) { - fmt.Printf("Gotgt %s -- HEAD\n", version.VERSION) + fmt.Printf("Gotgt %s -- HEAD\n", version.Version) }, } return cmd diff --git a/pkg/api/types.go b/pkg/api/types.go index ce41f00..443e619 100644 --- a/pkg/api/types.go +++ b/pkg/api/types.go @@ -177,8 +177,10 @@ type SCSICommand struct { } type ITNexus struct { - ID uuid.UUID `json:"id"` /*UUIDv1*/ - Tag string `json:"Tag"` /*For protocal spec identifer*/ + // UUID v1 + ID uuid.UUID `json:"id"` + // For protocal spec identifer + Tag string `json:"Tag"` } type ITNexusLuInfo struct { @@ -346,13 +348,17 @@ type SCSIDeviceProtocol interface { ExitLu(lu *SCSILu) error } type ModePage struct { - Pcode uint8 // Page code - SubPcode uint8 // Sub page code - Data []byte // Rest of mode page info + // Page code + PageCode uint8 + // Sub page code + SubPageCode uint8 + // Rest of mode page info + Data []byte } type SCSIReservation struct { - ID uuid.UUID //Internal Reservation ID + // Internal reservation ID + ID uuid.UUID Key uint64 ITNexusID uuid.UUID Scope uint8 diff --git a/pkg/apiserver/apiserver.go b/pkg/apiserver/apiserver.go index d758246..7f20ceb 100644 --- a/pkg/apiserver/apiserver.go +++ b/pkg/apiserver/apiserver.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Package apiserver contains the code that provides a rest.ful api service. +// Package apiserver contains the code that provides a rest.ful API service. package apiserver import ( diff --git a/pkg/apiserver/httputils/httputils.go b/pkg/apiserver/httputils/httputils.go index 4e5899c..01030e8 100644 --- a/pkg/apiserver/httputils/httputils.go +++ b/pkg/apiserver/httputils/httputils.go @@ -13,6 +13,8 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ + +// Package httputils contains a bunch of HTTP utility code, some generic package httputils import ( @@ -157,11 +159,11 @@ func WriteJSON(w http.ResponseWriter, code int, v interface{}) error { // It panics if the context value does not have version.Version type. func VersionFromContext(ctx context.Context) string { if ctx == nil { - return version.VERSION + return version.Version } val := ctx.Value(APIVersionKey) if val == nil { - return version.VERSION + return version.Version } return val.(string) } diff --git a/pkg/config/config.go b/pkg/config/config.go index cf9ab0a..092b81f 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -14,6 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ +// Package config contains how to get/save config parameters from file. package config import ( diff --git a/pkg/scsi/backingstore/backingstore.go b/pkg/scsi/backingstore/backingstore.go new file mode 100644 index 0000000..72360b6 --- /dev/null +++ b/pkg/scsi/backingstore/backingstore.go @@ -0,0 +1,18 @@ +/* +Copyright 2016 The GoStor Authors All rights reserved. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Package backingstore provides the plugin to connect backend storage. +package backingstore diff --git a/pkg/scsi/backingstore/common.go b/pkg/scsi/backingstore/common.go index 569b85e..ebf7116 100644 --- a/pkg/scsi/backingstore/common.go +++ b/pkg/scsi/backingstore/common.go @@ -164,7 +164,7 @@ write: glog.V(2).Infof("write data at %d for length %d", offset, length) var pg *api.ModePage for _, p := range lu.ModePages { - if p.Pcode == 0x08 && p.SubPcode == 0 { + if p.PageCode == 0x08 && p.SubPageCode == 0 { pg = &p break } diff --git a/pkg/scsi/backingstore/null.go b/pkg/scsi/backingstore/null.go index 57bb1ff..2b99bb6 100644 --- a/pkg/scsi/backingstore/null.go +++ b/pkg/scsi/backingstore/null.go @@ -1,5 +1,5 @@ /* -Copyright 2015 The GoStor Authors All rights reserved. +Copyright 2016 The GoStor Authors All rights reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/pkg/scsi/error.go b/pkg/scsi/error.go index e2b4d70..a179a5e 100644 --- a/pkg/scsi/error.go +++ b/pkg/scsi/error.go @@ -20,7 +20,7 @@ import "errors" type SCSIError struct { errno byte - Err error + err error } var ( @@ -58,7 +58,7 @@ var ( type SCSISubError uint16 var ( - /* Key 0: No Sense Errors */ + // Key 0: No Sense Errors NO_ADDITIONAL_SENSE SCSISubError = 0x0000 ASC_MARK SCSISubError = 0x0001 ASC_EOM SCSISubError = 0x0002 @@ -67,14 +67,14 @@ var ( ASC_OP_IN_PROGRESS SCSISubError = 0x0016 ASC_DRIVE_REQUIRES_CLEANING SCSISubError = 0x8282 - /* Key 1: Recovered Errors */ + // Key 1: Recovered Errors ASC_WRITE_ERROR SCSISubError = 0x0c00 ASC_READ_ERROR SCSISubError = 0x1100 ASC_RECOVERED_WITH_RETRYS SCSISubError = 0x1701 ASC_MEDIA_LOAD_EJECT_ERROR SCSISubError = 0x5300 ASC_FAILURE_PREDICTION SCSISubError = 0x5d00 - /* Key 2: Not ready */ + // Key 2: Not ready ASC_CAUSE_NOT_REPORTABLE SCSISubError = 0x0400 ASC_BECOMING_READY SCSISubError = 0x0401 ASC_INITIALIZING_REQUIRED SCSISubError = 0x0402 @@ -83,7 +83,7 @@ var ( ASC_MEDIUM_NOT_PRESENT SCSISubError = 0x3a00 ASC_LOGICAL_UNIT_NOT_CONFIG SCSISubError = 0x3e00 - /* Key 3: Medium Errors */ + // Key 3: Medium Errors ASC_UNRECOVERED_READ SCSISubError = 0x1100 ASC_RECORDED_ENTITY_NOT_FOUND SCSISubError = 0x1400 ASC_UNKNOWN_FORMAT SCSISubError = 0x3001 @@ -94,7 +94,7 @@ var ( ASC_CARTRIDGE_FAULT SCSISubError = 0x5200 ASC_MEDIA_LOAD_OR_EJECT_FAILED SCSISubError = 0x5300 - /* Key 4: Hardware Failure */ + // Key 4: Hardware Failure ASC_COMPRESSION_CHECK SCSISubError = 0x0c04 ASC_DECOMPRESSION_CRC SCSISubError = 0x110d ASC_MECHANICAL_POSITIONING_ERROR SCSISubError = 0x1501 @@ -103,7 +103,7 @@ var ( ASC_INTERNAL_TGT_FAILURE SCSISubError = 0x4400 ASC_ERASE_FAILURE SCSISubError = 0x5100 - /* Key 5: Illegal Request */ + // Key 5: Illegal Request ASC_PARAMETER_LIST_LENGTH_ERR SCSISubError = 0x1a00 ASC_INVALID_OP_CODE SCSISubError = 0x2000 ASC_LBA_OUT_OF_RANGE SCSISubError = 0x2100 @@ -120,7 +120,7 @@ var ( ASC_INSUFFICENT_REGISTRATION_RESOURCES SCSISubError = 0x5504 ASC_BAD_MICROCODE_DETECTED SCSISubError = 0x8283 - /* Key 6: Unit Attention */ + // Key 6: Unit Attention ASC_NOT_READY_TO_TRANSITION SCSISubError = 0x2800 ASC_POWERON_RESET SCSISubError = 0x2900 ASC_I_T_NEXUS_LOSS_OCCURRED SCSISubError = 0x2907 @@ -134,10 +134,10 @@ var ( ASC_REPORTED_LUNS_DATA_HAS_CHANGED SCSISubError = 0x3f0e ASC_FAILURE_PREDICTION_FALSE SCSISubError = 0x5dff - /* Data Protect */ + // Data Protect ASC_WRITE_PROTECT SCSISubError = 0x2700 ASC_MEDIUM_OVERWRITE_ATTEMPTED SCSISubError = 0x300c - /* Miscompare */ + // Miscompare ASC_MISCOMPARE_DURING_VERIFY_OPERATION SCSISubError = 0x1d00 ) diff --git a/pkg/scsi/lun.go b/pkg/scsi/lun.go index efcd88c..564f7ef 100644 --- a/pkg/scsi/lun.go +++ b/pkg/scsi/lun.go @@ -22,10 +22,8 @@ import ( "github.com/gostor/gotgt/pkg/api" ) -/* - * path format :/absolute/file/path - */ - +// NewSCSILu: create a new SCSI LU +// path format :/absolute/file/path func NewSCSILu(device_uuid uint64, path string, online bool) (*api.SCSILu, error) { pathinfo := strings.SplitN(path, ":", 2) @@ -60,6 +58,7 @@ func NewSCSILu(device_uuid uint64, path string, online bool) (*api.SCSILu, error return lu, nil } +// NewLUN0: create a new fake SCSI LU func NewLUN0() *api.SCSILu { sbc := NewSBCDevice(api.TYPE_UNKNOWN) diff --git a/pkg/scsi/sbc.go b/pkg/scsi/sbc.go index 74c07e2..b194125 100644 --- a/pkg/scsi/sbc.go +++ b/pkg/scsi/sbc.go @@ -66,7 +66,7 @@ func (sbc SBCSCSIDeviceProtocol) InitLu(lu *api.SCSILu) error { lu.Attrs.SenseFormat = false lu.Attrs.VendorID = SCSIVendorID lu.Attrs.ProductID = SCSIProductID - lu.Attrs.ProductRev = version.SCSI_VERSION + lu.Attrs.ProductRev = version.SCSIVersion /* SCSIID for PAGE83 T10 VENDOR IDENTIFICATION field diff --git a/pkg/util/util.go b/pkg/util/util.go index 3f76d4e..8c4042e 100644 --- a/pkg/util/util.go +++ b/pkg/util/util.go @@ -14,6 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ +// Package util provides some basic util functions. package util import ( diff --git a/pkg/version/version.go b/pkg/version/version.go index 3856c64..82db0ec 100644 --- a/pkg/version/version.go +++ b/pkg/version/version.go @@ -1,5 +1,5 @@ /* -Copyright 2015 The GoStor Authors All rights reserved. +Copyright 2016 The GoStor Authors All rights reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,9 +14,11 @@ See the License for the specific language governing permissions and limitations under the License. */ +// Package version provides the Version information. package version const ( - VERSION = "0.1" - SCSI_VERSION = "0.1" /* SCSI version string MUST be shorter than 4 characters*/ + Version = "0.1" + // SCSI version string MUST be shorter than 4 characters + SCSIVersion = "0.1" )