mirror of
https://github.com/minio/minio.git
synced 2025-11-21 02:09:08 -05:00
Improve disk code to return back disk StatFS{} structure
```
StatFS {
Total int64
Free int64
FSType string
}
```
Provides more information in a cross platform way.
This commit is contained in:
@@ -23,13 +23,18 @@ import (
|
||||
)
|
||||
|
||||
// Stat returns total and free bytes available in a directory, e.g. `/`.
|
||||
func Stat(path string) (total, free int64, err error) {
|
||||
func Stat(path string) (statfs StatFS, err error) {
|
||||
s := syscall.Statfs_t{}
|
||||
err = syscall.Statfs(path, &s)
|
||||
if err != nil {
|
||||
return
|
||||
return StatFS{}, err
|
||||
}
|
||||
total = int64(s.Bsize) * int64(s.Blocks)
|
||||
free = int64(s.Bsize) * int64(s.Bfree)
|
||||
return
|
||||
statfs = StatFS{}
|
||||
statfs.Total = int64(s.Bsize) * int64(s.Blocks)
|
||||
statfs.Free = int64(s.Bsize) * int64(s.Bfree)
|
||||
statfs.FSType, err = getFSType(path)
|
||||
if err != nil {
|
||||
return StatFS{}, err
|
||||
}
|
||||
return statfs, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user