Solaris/illumos use Statvfs (POSIX standard) rather than Statfs. Add daemon_health_solaris.go and exclude illumos/solaris from the generic unix build constraint. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
24 lines
677 B
Go
24 lines
677 B
Go
//go:build !windows && !wasm && !freebsd && !illumos && !solaris
|
|
|
|
package main
|
|
|
|
import (
|
|
"golang.org/x/sys/unix"
|
|
)
|
|
|
|
// checkDiskSpace returns the available disk space in MB for the given path.
|
|
// Returns (availableMB, true) on success, (0, false) on failure.
|
|
func checkDiskSpace(path string) (uint64, bool) {
|
|
var stat unix.Statfs_t
|
|
if err := unix.Statfs(path, &stat); err != nil {
|
|
return 0, false
|
|
}
|
|
|
|
// Calculate available space in bytes, then convert to MB.
|
|
// On most unix platforms, Bavail is unsigned but Bsize is signed.
|
|
availableBytes := stat.Bavail * uint64(stat.Bsize) //nolint:gosec
|
|
availableMB := availableBytes / (1024 * 1024)
|
|
|
|
return availableMB, true
|
|
}
|