This commit is contained in:
npc0-hue
2026-08-26 09:56:43 +08:00
parent 2b4974b561
commit 8e02a316fa
93 changed files with 21749 additions and 0 deletions
+16
View File
@@ -0,0 +1,16 @@
//go:build !windows
package runtime
import "syscall"
func workspaceDiskPercent(workspaceRoot string) (float64, error) {
var stat syscall.Statfs_t
if err := syscall.Statfs(workspaceRoot, &stat); err != nil {
return 0, err
}
if stat.Blocks == 0 {
return 0, syscall.EINVAL
}
return 100 * float64(stat.Blocks-stat.Bavail) / float64(stat.Blocks), nil
}