mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2024-12-13 13:11:37 +01:00
lib/fs: use unix.Statfs()
/ unix.Statvfs()
when using a path (#3663)
This commit is contained in:
parent
09d41e05fa
commit
63653b53d6
@ -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 New Issue
Block a user