From fd5bea7ff9976d9393a1e6dbcb5f4af4e8225cf3 Mon Sep 17 00:00:00 2001 From: Nahum Shalman Date: Mon, 29 Dec 2025 17:43:00 -0500 Subject: [PATCH] fix: add illumos/solaris support for disk space check (#798) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- cmd/bd/daemon_health_solaris.go | 23 +++++++++++++++++++++++ cmd/bd/daemon_health_unix.go | 2 +- 2 files changed, 24 insertions(+), 1 deletion(-) create mode 100644 cmd/bd/daemon_health_solaris.go diff --git a/cmd/bd/daemon_health_solaris.go b/cmd/bd/daemon_health_solaris.go new file mode 100644 index 00000000..fba21385 --- /dev/null +++ b/cmd/bd/daemon_health_solaris.go @@ -0,0 +1,23 @@ +//go:build 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.Statvfs_t + if err := unix.Statvfs(path, &stat); err != nil { + return 0, false + } + + // Calculate available space in bytes, then convert to MB. + // On Solaris/illumos, Frsize is the fragment size (fundamental block size). + availableBytes := stat.Bavail * stat.Frsize + availableMB := availableBytes / (1024 * 1024) + + return availableMB, true +} diff --git a/cmd/bd/daemon_health_unix.go b/cmd/bd/daemon_health_unix.go index 4ba292d0..52e18f24 100644 --- a/cmd/bd/daemon_health_unix.go +++ b/cmd/bd/daemon_health_unix.go @@ -1,4 +1,4 @@ -//go:build !windows && !wasm && !freebsd +//go:build !windows && !wasm && !freebsd && !illumos && !solaris package main