mirror of
https://github.com/minio/minio.git
synced 2025-11-08 21:24:55 -05:00
@@ -1,7 +1,7 @@
|
||||
// +build darwin freebsd dragonfly
|
||||
// +build darwin dragonfly
|
||||
|
||||
/*
|
||||
* MinIO Cloud Storage, (C) 2015, 2016, 2017 MinIO, Inc.
|
||||
* MinIO Cloud Storage, (C) 2015-2021 MinIO, Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -30,12 +30,12 @@ func GetInfo(path string) (info Info, err error) {
|
||||
if err != nil {
|
||||
return Info{}, err
|
||||
}
|
||||
reservedBlocks := uint64(s.Bfree) - uint64(s.Bavail)
|
||||
reservedBlocks := s.Bfree - s.Bavail
|
||||
info = Info{
|
||||
Total: uint64(s.Bsize) * (uint64(s.Blocks) - reservedBlocks),
|
||||
Free: uint64(s.Bsize) * uint64(s.Bavail),
|
||||
Files: uint64(s.Files),
|
||||
Ffree: uint64(s.Ffree),
|
||||
Total: uint64(s.Bsize) * (s.Blocks - reservedBlocks),
|
||||
Free: uint64(s.Bsize) * s.Bavail,
|
||||
Files: s.Files,
|
||||
Ffree: s.Ffree,
|
||||
FSType: getFSType(s.Fstypename[:]),
|
||||
}
|
||||
if info.Free > info.Total {
|
||||
|
||||
46
pkg/disk/stat_freebsd.go
Normal file
46
pkg/disk/stat_freebsd.go
Normal file
@@ -0,0 +1,46 @@
|
||||
// +build freebsd
|
||||
|
||||
/*
|
||||
* MinIO Cloud Storage, (C) 2021 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 disk
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"syscall"
|
||||
)
|
||||
|
||||
// GetInfo returns total and free bytes available in a directory, e.g. `/`.
|
||||
func GetInfo(path string) (info Info, err error) {
|
||||
s := syscall.Statfs_t{}
|
||||
err = syscall.Statfs(path, &s)
|
||||
if err != nil {
|
||||
return Info{}, err
|
||||
}
|
||||
reservedBlocks := s.Bfree - uint64(s.Bavail)
|
||||
info = Info{
|
||||
Total: uint64(s.Bsize) * (s.Blocks - reservedBlocks),
|
||||
Free: uint64(s.Bsize) * uint64(s.Bavail),
|
||||
Files: s.Files,
|
||||
Ffree: uint64(s.Ffree),
|
||||
FSType: getFSType(s.Fstypename[:]),
|
||||
}
|
||||
if info.Free > info.Total {
|
||||
return info, fmt.Errorf("detected free space (%d) > total disk space (%d), fs corruption at (%s). please run 'fsck'", info.Free, info.Total, path)
|
||||
}
|
||||
info.Used = info.Total - info.Free
|
||||
return info, nil
|
||||
}
|
||||
@@ -19,7 +19,7 @@ package smart
|
||||
import "math/big"
|
||||
|
||||
// Defined in <linux/nvme_ioctl.h>
|
||||
//nolint:structcheck
|
||||
//nolint:structcheck,deadcode
|
||||
type nvmePassthruCommand struct {
|
||||
opcode uint8
|
||||
flags uint8
|
||||
@@ -59,6 +59,7 @@ type nvmeIdentPowerState struct {
|
||||
Rsvd23 [9]byte
|
||||
}
|
||||
|
||||
//nolint:deadcode
|
||||
type nvmeIdentController struct {
|
||||
VendorID uint16 // PCI Vendor ID
|
||||
Ssvid uint16 // PCI Subsystem Vendor ID
|
||||
@@ -150,6 +151,7 @@ type nvmeIdentNamespace struct {
|
||||
Vs [3712]byte
|
||||
} // 4096 bytes
|
||||
|
||||
//nolint:deadcode
|
||||
type nvmeSMARTLog struct {
|
||||
CritWarning uint8
|
||||
Temperature [2]uint8
|
||||
@@ -174,6 +176,7 @@ type nvmeSMARTLog struct {
|
||||
} // 512 bytes
|
||||
|
||||
// NVMeDevice represents drive data about NVMe drives
|
||||
//nolint:structcheck
|
||||
type NVMeDevice struct {
|
||||
Name string
|
||||
fd int
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// +build darwin
|
||||
|
||||
/*
|
||||
* MinIO Cloud Storage, (C) 2016,2017 MinIO, Inc.
|
||||
* MinIO Cloud Storage, (C) 2016-2021 MinIO, Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -33,9 +33,7 @@ func getHwMemsize() (uint64, error) {
|
||||
// removes the last byte of the result if it's 0 :/
|
||||
totalString += "\x00"
|
||||
|
||||
total := uint64(binary.LittleEndian.Uint64([]byte(totalString)))
|
||||
|
||||
return total, nil
|
||||
return binary.LittleEndian.Uint64([]byte(totalString)), nil
|
||||
}
|
||||
|
||||
// GetStats - return system statistics for macOS.
|
||||
|
||||
Reference in New Issue
Block a user