mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2024-11-21 14:44:00 +00:00
lib/fs: use unix.Statfs()
/ unix.Statvfs()
when using a path (#3663)
This commit is contained in:
parent
5cb8ce8174
commit
46b3b76d6d
2 changed files with 2 additions and 16 deletions
|
@ -49,15 +49,8 @@ func createFlockFile(flockFile string) (*os.File, error) {
|
|||
}
|
||||
|
||||
func mustGetFreeSpace(path string) uint64 {
|
||||
d, err := os.Open(path)
|
||||
if err != nil {
|
||||
logger.Panicf("FATAL: cannot open dir for determining free disk space: %s", err)
|
||||
}
|
||||
defer MustClose(d)
|
||||
|
||||
fd := d.Fd()
|
||||
var stat unix.Statvfs_t
|
||||
if err := unix.Fstatvfs(int(fd), &stat); err != nil {
|
||||
if err := unix.Statvfs(path, &stat); err != nil {
|
||||
logger.Panicf("FATAL: cannot determine free disk space on %q: %s", path, err)
|
||||
}
|
||||
return freeSpace(stat)
|
||||
|
|
|
@ -45,15 +45,8 @@ func createFlockFile(flockFile string) (*os.File, error) {
|
|||
}
|
||||
|
||||
func mustGetFreeSpace(path string) uint64 {
|
||||
d, err := os.Open(path)
|
||||
if err != nil {
|
||||
logger.Panicf("FATAL: cannot open dir for determining free disk space: %s", err)
|
||||
}
|
||||
defer MustClose(d)
|
||||
|
||||
fd := d.Fd()
|
||||
var stat unix.Statfs_t
|
||||
if err := unix.Fstatfs(int(fd), &stat); err != nil {
|
||||
if err := unix.Statfs(path, &stat); err != nil {
|
||||
logger.Panicf("FATAL: cannot determine free disk space on %q: %s", path, err)
|
||||
}
|
||||
return freeSpace(stat)
|
||||
|
|
Loading…
Reference in a new issue