diff --git a/Makefile b/Makefile index 8b764fe1a..b86c37178 100644 --- a/Makefile +++ b/Makefile @@ -20,9 +20,9 @@ build-utils: @godep go test -race -coverprofile=cover.out github.com/minio-io/minio/pkg/utils/crypto/sha512/ @godep go test -race -coverprofile=cover.out github.com/minio-io/minio/pkg/utils/checksum/crc32c -build-os: - @godep go test -race -coverprofile=cover.out github.com/minio-io/minio/pkg/os/scsi - @godep go test -race -coverprofile=cover.out github.com/minio-io/minio/pkg/os/sysctl +#build-os: +# @godep go test -race -coverprofile=cover.out github.com/minio-io/minio/pkg/os/scsi +# @godep go test -race -coverprofile=cover.out github.com/minio-io/minio/pkg/os/sysctl build-storage: @$(MAKE) $(MAKE_OPTIONS) -C pkg/storage/erasure/isal lib @@ -31,7 +31,7 @@ build-storage: build-minioapi: @godep go test -race -coverprofile=cover.out github.com/minio-io/minio/pkg/webapi/minioapi -cover: build-storage build-os build-utils build-minioapi +cover: build-storage build-utils build-minioapi install: cover diff --git a/pkg/os/scsi/.gitignore b/pkg/os/scsi/.gitignore deleted file mode 100644 index e810a59ed..000000000 --- a/pkg/os/scsi/.gitignore +++ /dev/null @@ -1 +0,0 @@ -scsi \ No newline at end of file diff --git a/pkg/os/scsi/constants_linux.go b/pkg/os/scsi/constants_linux.go deleted file mode 100644 index e8ac1eabd..000000000 --- a/pkg/os/scsi/constants_linux.go +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Mini Object Storage, (C) 2014 Minio, Inc. - * - * 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. - */ - -// !build linux,amd64 - -package scsi - -var ( - // From 2.6.x kernel onwards, no need to support procfs - SYSFS_SCSI_DEVICES = "/sys/bus/scsi/devices/" - SYSFS_BLOCK = "/sys/block/" - SYSFS_CLASS_SCSI_DEVICES = "/sys/class/scsi_device/" - UDEV = "/dev/" - DEV_DISK_BYID_DIR = "/dev/disk/by-id" -) - -var SCSI_DEVICE_TYPES = []string{ - "disk", - "tape", - "printer", - "process", - "worm", - "cd/dvd", - "scanner", - "optical", - "mediumx", - "comms", - "(0xa)", - "(0xb)", - "storage", - "enclosu", - "sim disk", - "optical rd", - "bridge", - "osd", - "adi", - "sec man", - "zbc", - "(0x15)", - "(0x16)", - "(0x17)", - "(0x18)", - "(0x19)", - "(0x1a)", - "(0x1b)", - "(0x1c)", - "(0x1e)", - "wlun", - "no dev", -} diff --git a/pkg/os/scsi/errors.go b/pkg/os/scsi/errors.go deleted file mode 100644 index 46eb15d3d..000000000 --- a/pkg/os/scsi/errors.go +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Mini Object Storage, (C) 2015 Minio, Inc. - * - * 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 scsi - -type NoDiskAttributesFound struct{} - -func (self NoDiskAttributesFound) Error() string { - return "No Disk Attributes Found" -} - -type NoDiskQueueAttributesFound struct{} - -func (self NoDiskQueueAttributesFound) Error() string { - return "No Disk Queue Attributes Found" -} - -type NoScsiDevicesFoundOnSystem struct{} - -func (self NoScsiDevicesFoundOnSystem) Error() string { - return "No scsi devices found on the system" -} - -type ScsiAddressPointsToMultipleBlockDevices struct{} - -func (self ScsiAddressPointsToMultipleBlockDevices) Error() string { - return "Scsi address points to multiple block devices" -} - -type NoScsiAttributesFound struct{} - -func (self NoScsiAttributesFound) Error() string { - return "No Scsi Attributes Found" -} diff --git a/pkg/os/scsi/scsi_linux.go b/pkg/os/scsi/scsi_linux.go deleted file mode 100644 index 190f02ffa..000000000 --- a/pkg/os/scsi/scsi_linux.go +++ /dev/null @@ -1,169 +0,0 @@ -/* - * Mini Object Storage, (C) 2014 Minio, Inc. - * - * 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. - */ - -// !build linux,amd64 - -package scsi - -import ( - "io/ioutil" - "path" -) - -// NOTE : supporting virtio based scsi devices -// is out of scope for this implementation - -type Scsi struct { - Disk string - Scsiattrmap map[string][]byte - Diskattrmap map[string][]byte -} - -type Devices struct { - List []Scsi -} - -func (d *Devices) getInfo(disk string) (map[string][]byte, error) { - var diskAttrsList []string - var diskQueueAttrs []string - aggrAttrMap := make(map[string][]byte) - - sysfs_block_dev := path.Join(SYSFS_BLOCK + disk) - sysfs_block_dev_queue := path.Join(sysfs_block_dev + "/queue") - - scsiFiles, err := ioutil.ReadDir(sysfs_block_dev) - if err != nil { - return nil, err - } - - scsiQueueFiles, err := ioutil.ReadDir(sysfs_block_dev_queue) - if err != nil { - return nil, err - } - - for _, sf := range scsiFiles { - if sf.IsDir() { - continue - } - // Skip symlinks - if !sf.Mode().IsRegular() { - continue - } - // Skip, not readable, write-only - if sf.Mode().Perm() == 128 { - continue - } - diskAttrsList = append(diskAttrsList, sf.Name()) - } - - for _, sf := range scsiQueueFiles { - if sf.IsDir() { - continue - } - // Skip symlinks - if !sf.Mode().IsRegular() { - continue - } - // Skip, not readable, write-only - if sf.Mode().Perm() == 128 { - continue - } - diskQueueAttrs = append(diskQueueAttrs, sf.Name()) - } - - if len(diskAttrsList) == 0 { - return nil, NoDiskAttributesFound{} - } - - if len(diskQueueAttrs) == 0 { - return nil, NoDiskQueueAttributesFound{} - } - - diskAttrMap := getattrs(sysfs_block_dev, diskAttrsList) - diskQueueAttrMap := getattrs(sysfs_block_dev_queue, diskQueueAttrs) - - for k, v := range diskAttrMap { - aggrAttrMap[k] = v - } - - for k, v := range diskQueueAttrMap { - aggrAttrMap[k] = v - } - - return aggrAttrMap, nil -} - -func (d *Devices) Get() error { - var scsidevices []string - var scsiAttrList []string - - sysFiles, err := ioutil.ReadDir(SYSFS_SCSI_DEVICES) - if err != nil { - return err - } - - scsidevices = filterdevices(sysFiles) - if len(scsidevices) == 0 { - return NoScsiDevicesFoundOnSystem{} - } - - for _, scsi := range scsidevices { - var _scsi Scsi - scsiAttrPath := path.Join(SYSFS_SCSI_DEVICES, scsi, "/") - scsiAttrs, err := ioutil.ReadDir(scsiAttrPath) - if err != nil { - return err - } - scsiBlockPath := path.Join(SYSFS_SCSI_DEVICES, scsi, "/block") - scsidevList, err := ioutil.ReadDir(scsiBlockPath) - if err != nil { - return err - } - - if len(scsidevList) > 1 { - return ScsiAddressPointsToMultipleBlockDevices{} - } - - _scsi.Disk = UDEV + scsidevList[0].Name() - for _, sa := range scsiAttrs { - // Skip directories - if sa.IsDir() { - continue - } - // Skip symlinks - if !sa.Mode().IsRegular() { - continue - } - // Skip, not readable, write-only - if sa.Mode().Perm() == 128 { - continue - } - scsiAttrList = append(scsiAttrList, sa.Name()) - } - - if len(scsiAttrList) == 0 { - return NoScsiAttributesFound{} - } - attrMap := getattrs(scsiAttrPath, scsiAttrList) - _scsi.Scsiattrmap = attrMap - _scsi.Diskattrmap, err = d.getInfo(scsidevList[0].Name()) - if err != nil { - return err - } - d.List = append(d.List, _scsi) - } - return nil -} diff --git a/pkg/os/scsi/scsi_test.go b/pkg/os/scsi/scsi_test.go deleted file mode 100644 index 6d0f29b97..000000000 --- a/pkg/os/scsi/scsi_test.go +++ /dev/null @@ -1,23 +0,0 @@ -// !build linux,amd64 -package scsi - -import ( - . "gopkg.in/check.v1" - "testing" -) - -type MySuite struct{} - -var _ = Suite(&MySuite{}) - -func Test(t *testing.T) { TestingT(t) } - -func (s *MySuite) TestSCSI(c *C) { - var d Devices - err := d.Get() - c.Assert(err, IsNil) - c.Assert(len(d.List), Equals, 1) - - c.Assert(len(d.List[0].Scsiattrmap), Not(Equals), 0) - c.Assert(len(d.List[0].Diskattrmap), Not(Equals), 0) -} diff --git a/pkg/os/scsi/utils_linux.go b/pkg/os/scsi/utils_linux.go deleted file mode 100644 index 19cc04c2c..000000000 --- a/pkg/os/scsi/utils_linux.go +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Mini Object Storage, (C) 2014 Minio, Inc. - * - * 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. - */ - -// !build linux,amd64 - -package scsi - -import ( - "io/ioutil" - "os" - "path" - "strings" -) - -func getattrs(scsiAttrPath string, scsiAttrList []string) map[string][]byte { - attrMap := make(map[string][]byte) - for _, attr := range scsiAttrList { - value, _ := ioutil.ReadFile(path.Join(scsiAttrPath, attr)) - attrMap[attr] = value - } - return attrMap -} - -func filterdevices(files []os.FileInfo) (scsidevices []string) { - for _, fi := range files { - if strings.Contains(fi.Name(), "host") { - continue - } - if strings.Contains(fi.Name(), "target") { - continue - } - scsidevices = append(scsidevices, fi.Name()) - } - return scsidevices -} diff --git a/pkg/os/sysctl/sysctl_linux.go b/pkg/os/sysctl/sysctl_linux.go deleted file mode 100644 index 332b09ca9..000000000 --- a/pkg/os/sysctl/sysctl_linux.go +++ /dev/null @@ -1,52 +0,0 @@ -// !build linux,amd64 - -package sysctl - -import ( - "bufio" - "os/exec" - "strings" - - "github.com/minio-io/minio/pkg/utils" -) - -type Sysctl struct { - Sysattrmap map[string][]byte -} - -func (s *Sysctl) Get() error { - attrMap := make(map[string][]byte) - - // Get full system level list - sysctl_cmd := exec.Command("sysctl", "-a") - // Sort the output and throw away duplicate keys - sort_cmd := exec.Command("sort", "-u") - // Ignore permission denied errors from sysctl output - grep_cmd := exec.Command("grep", "-v", "permission") - - output, err := utils.ExecPipe(sysctl_cmd, sort_cmd, grep_cmd) - if err != nil { - return err - } - - scanner := bufio.NewScanner(output) - split := func(data []byte, atEOF bool) (advance int, token []byte, err error) { - advance, token, err = bufio.ScanLines(data, atEOF) - return - } - - scanner.Split(split) - - for scanner.Scan() { - split := strings.Split(scanner.Text(), "=") - if len(split) < 1 { - println("Invalid token skip..") - continue - } - k, v := strings.TrimSpace(split[0]), strings.TrimSpace(split[1]) - attrMap[k] = []byte(v) - } - - s.Sysattrmap = attrMap - return nil -} diff --git a/pkg/os/sysctl/sysctl_test.go b/pkg/os/sysctl/sysctl_test.go deleted file mode 100644 index fdfc6aa2a..000000000 --- a/pkg/os/sysctl/sysctl_test.go +++ /dev/null @@ -1,22 +0,0 @@ -// !build linux,amd64 - -package sysctl - -import ( - "testing" - - . "gopkg.in/check.v1" -) - -type MySuite struct{} - -var _ = Suite(&MySuite{}) - -func Test(t *testing.T) { TestingT(t) } - -func (s *MySuite) TestSysctl(c *C) { - sysctl := Sysctl{} - err := sysctl.Get() - c.Assert(err, IsNil) - c.Assert(sysctl.Sysattrmap, Not(Equals), 0) -}