mirror of
https://github.com/minio/minio.git
synced 2025-04-24 12:21:02 -04:00
use statvfs(2) for disk.GetInfo on NetBSD (#10257)
This commit is contained in:
parent
a2a5ec93d3
commit
052b5262ff
@ -1,7 +1,7 @@
|
|||||||
// +build netbsd
|
// +build netbsd
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* MinIO Cloud Storage, (C) 2017 MinIO, Inc.
|
* MinIO Cloud Storage, (C) 2020 MinIO, Inc.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@ -18,7 +18,23 @@
|
|||||||
|
|
||||||
package disk
|
package disk
|
||||||
|
|
||||||
|
import (
|
||||||
|
"golang.org/x/sys/unix"
|
||||||
|
)
|
||||||
|
|
||||||
// GetInfo returns total and free bytes available in a directory, e.g. `/`.
|
// GetInfo returns total and free bytes available in a directory, e.g. `/`.
|
||||||
func GetInfo(path string) (info Info, err error) {
|
func GetInfo(path string) (info Info, err error) {
|
||||||
return Info{}, nil
|
s := unix.Statvfs_t{}
|
||||||
|
if err = unix.Statvfs(path, &s); err != nil {
|
||||||
|
return Info{}, err
|
||||||
|
}
|
||||||
|
reservedBlocks := uint64(s.Bfree) - uint64(s.Bavail)
|
||||||
|
info = Info{
|
||||||
|
Total: uint64(s.Frsize) * (uint64(s.Blocks) - reservedBlocks),
|
||||||
|
Free: uint64(s.Frsize) * uint64(s.Bavail),
|
||||||
|
Files: uint64(s.Files),
|
||||||
|
Ffree: uint64(s.Ffree),
|
||||||
|
FSType: string(s.Fstypename[:]),
|
||||||
|
}
|
||||||
|
return info, nil
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user