mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2024-11-23 20:37:12 +01:00
f3a03c4164
* fixes windows compilation, adds signal impl for windows, adds free space usage for windows, https://github.com/VictoriaMetrics/VictoriaMetrics/issues/70 https://github.com/VictoriaMetrics/VictoriaMetrics/issues/1036 NOTE victoria metrics database still CANNOT work under windows system, only vmagent is supported. To completly port victoria metrics, you have to fix issues with separators, parsing and posix file removall * rollback separator * Adds windows setInformation api, it must behave like unix, need to test it. changes procutil * check for invlaid param * Fixes posix delete semantic * refactored a bit * fixes openbsd build * removed windows api call * Fixes code after windows add * Update lib/procutil/signal_windows.go Co-authored-by: Aliaksandr Valialkin <valyala@gmail.com>
30 lines
633 B
Go
30 lines
633 B
Go
// +build linux darwin freebsd
|
|
|
|
package fs
|
|
|
|
import (
|
|
"os"
|
|
|
|
"github.com/VictoriaMetrics/VictoriaMetrics/lib/logger"
|
|
"golang.org/x/sys/unix"
|
|
)
|
|
|
|
func mustGetFreeSpace(path string) uint64 {
|
|
d, err := os.Open(path)
|
|
if err != nil {
|
|
logger.Panicf("FATAL: cannot determine free disk space on %q: %s", path, err)
|
|
}
|
|
defer MustClose(d)
|
|
|
|
fd := d.Fd()
|
|
var stat unix.Statfs_t
|
|
if err := unix.Fstatfs(int(fd), &stat); err != nil {
|
|
logger.Panicf("FATAL: cannot determine free disk space on %q: %s", path, err)
|
|
}
|
|
return freeSpace(stat)
|
|
}
|
|
|
|
func freeSpace(stat unix.Statfs_t) uint64 {
|
|
return uint64(stat.Bavail) * uint64(stat.Bsize)
|
|
}
|