Fix OS X build

- Explicitly cast statfs_t members to int64 (this structure is
   platform-specific)
 - Add pass-through New methods to Darwin SHA package
 - Move scsi pkg types to common translation unit (package was empty)
 - Add stub implementations mount/disk ops for OS X
This commit is contained in:
Nate Rosenblum 2015-07-13 08:26:40 -07:00
parent 74e44cd0c4
commit ec347f96fd
9 changed files with 80 additions and 26 deletions

View File

@ -17,6 +17,7 @@
package sha256
import (
"hash"
"io"
"crypto/sha256"
@ -45,3 +46,8 @@ func Sum(reader io.Reader) ([]byte, error) {
}
return d.Sum(nil), nil
}
// New returns a new hash.Hash computing SHA256.
func New() hash.Hash {
return sha256.New()
}

View File

@ -17,6 +17,7 @@
package sha512
import (
"hash"
"io"
"crypto/sha512"
@ -61,3 +62,8 @@ func SumStream(reader io.Reader) ([sha512.Size]byte, error) {
copy(returnValue[:], sumSlice)
return returnValue, err
}
// New returns a new hash.Hash computing SHA512.
func New() hash.Hash {
return sha512.New()
}

View File

@ -63,8 +63,8 @@ func New(diskPath string) (Disk, error) {
disk.fsInfo["MountPoint"] = disk.path
return disk, nil
}
return Disk{}, iodine.New(UnsupportedFilesystem{Type: strconv.FormatInt(s.Type, 10)},
map[string]string{"Type": strconv.FormatInt(s.Type, 10)})
return Disk{}, iodine.New(UnsupportedFilesystem{Type: strconv.FormatInt(int64(s.Type), 10)},
map[string]string{"Type": strconv.FormatInt(int64(s.Type), 10)})
}
// GetPath - get root disk path
@ -82,10 +82,10 @@ func (disk Disk) GetFSInfo() map[string]string {
if err != nil {
return nil
}
disk.fsInfo["Total"] = formatBytes(s.Bsize * int64(s.Blocks))
disk.fsInfo["Free"] = formatBytes(s.Bsize * int64(s.Bfree))
disk.fsInfo["TotalB"] = strconv.FormatInt(s.Bsize*int64(s.Blocks), 10)
disk.fsInfo["FreeB"] = strconv.FormatInt(s.Bsize*int64(s.Bfree), 10)
disk.fsInfo["Total"] = formatBytes(int64(s.Bsize) * int64(s.Blocks))
disk.fsInfo["Free"] = formatBytes(int64(s.Bsize) * int64(s.Bfree))
disk.fsInfo["TotalB"] = strconv.FormatInt(int64(s.Bsize)*int64(s.Blocks), 10)
disk.fsInfo["FreeB"] = strconv.FormatInt(int64(s.Bsize)*int64(s.Bfree), 10)
return disk.fsInfo
}

View File

@ -31,16 +31,6 @@ import (
"github.com/minio/minio/pkg/iodine"
)
// Mountinfo container to capture /etc/mtab mount structure
type Mountinfo struct {
FSName string /* name of mounted filesystem */
Dir string /* filesystem path prefix */
Type string /* mount type (see mntent.h) */
Opts string /* mount options (see mntent.h) */
Freq int /* dump frequency in days */
Passno int /* pass number on parallel fsck */
}
var supportedFSType = map[string]bool{
"ext4": true,
"xfs": true,

View File

@ -0,0 +1,23 @@
/*
* 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.
*/
package scsi
// GetMountInfo - get mount info map
func GetMountInfo() (map[string]Mountinfo, error) {
// Stub implementation; returns an empty map
return make(map[string]Mountinfo), nil
}

View File

@ -1,5 +1,3 @@
// +build linux,amd64
/*
* Mini Object Storage, (C) 2014 Minio, Inc.
*
@ -25,6 +23,22 @@ import (
"strings"
)
// Attributes Scsi device attributes
type Attributes map[string]string
// Disks is a list of scsis disks and attributes
type Disks map[string]Attributes
// Mountinfo container to capture /etc/mtab mount structure
type Mountinfo struct {
FSName string /* name of mounted filesystem */
Dir string /* filesystem path prefix */
Type string /* mount type (see mntent.h) */
Opts string /* mount options (see mntent.h) */
Freq int /* dump frequency in days */
Passno int /* pass number on parallel fsck */
}
func getattrs(scsiAttrPath string, scsiAttrList []string) map[string]string {
attrMap := make(map[string]string)
for _, attr := range scsiAttrList {

View File

@ -28,12 +28,6 @@ import (
// NOTE : supporting virtio based scsi devices is out of scope for this implementation
// Attributes Scsi device attributes
type Attributes map[string]string
// Disks is a list of scsis disks and attributes
type Disks map[string]Attributes
// Get get disk scsi params
func (d Disks) Get(disk string) Attributes {
return d[disk]

View File

@ -0,0 +1,23 @@
/*
* Minimalist 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
// GetDisks - get system devices list
func GetDisks() (Disks, error) {
// Stub implementation; returns empty disk information
return Disks{}, nil
}

View File

@ -1,5 +1,3 @@
// +build linux,amd64
/*
* Minimalist Object Storage, (C) 2015 Minio, Inc.
*