You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
40 lines
1.1 KiB
40 lines
1.1 KiB
8 years ago
|
// +build linux
|
||
9 years ago
|
|
||
|
/*
|
||
8 years ago
|
* Minio Cloud Storage, (C) 2015, 2016, 2017 Minio, Inc.
|
||
9 years ago
|
*
|
||
|
* 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 (
|
||
|
"syscall"
|
||
|
)
|
||
|
|
||
9 years ago
|
// GetInfo returns total and free bytes available in a directory, e.g. `/`.
|
||
|
func GetInfo(path string) (info Info, err error) {
|
||
9 years ago
|
s := syscall.Statfs_t{}
|
||
|
err = syscall.Statfs(path, &s)
|
||
|
if err != nil {
|
||
9 years ago
|
return Info{}, err
|
||
9 years ago
|
}
|
||
9 years ago
|
info = Info{}
|
||
|
info.Total = int64(s.Bsize) * int64(s.Blocks)
|
||
8 years ago
|
info.Free = int64(s.Bsize) * int64(s.Bavail)
|
||
9 years ago
|
info.Files = int64(s.Files)
|
||
|
info.Ffree = int64(s.Ffree)
|
||
8 years ago
|
info.FSType = getFSType(int64(s.Type))
|
||
9 years ago
|
return info, nil
|
||
9 years ago
|
}
|