Fix Linux amd64 Statfs Type cast for media-node disk dedupe build.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
parent
106aa996a4
commit
54d70735d8
2 changed files with 13 additions and 7 deletions
|
|
@ -4,18 +4,17 @@ package health
|
||||||
|
|
||||||
import "syscall"
|
import "syscall"
|
||||||
|
|
||||||
type fsKey struct {
|
|
||||||
typ int32
|
|
||||||
val0 int32
|
|
||||||
val1 int32
|
|
||||||
}
|
|
||||||
|
|
||||||
func diskStat(path string) (total, free uint64, fs fsKey, ok bool) {
|
func diskStat(path string) (total, free uint64, fs fsKey, ok bool) {
|
||||||
var st syscall.Statfs_t
|
var st syscall.Statfs_t
|
||||||
if err := syscall.Statfs(path, &st); err != nil {
|
if err := syscall.Statfs(path, &st); err != nil {
|
||||||
return 0, 0, fsKey{}, false
|
return 0, 0, fsKey{}, false
|
||||||
}
|
}
|
||||||
fs = fsKey{typ: st.Type, val0: st.Fsid.X__val[0], val1: st.Fsid.X__val[1]}
|
// st.Type is int64 on amd64 / int32 on some arches — always widen.
|
||||||
|
fs = fsKey{
|
||||||
|
typ: int64(st.Type),
|
||||||
|
val0: st.Fsid.X__val[0],
|
||||||
|
val1: st.Fsid.X__val[1],
|
||||||
|
}
|
||||||
total = st.Blocks * uint64(st.Bsize)
|
total = st.Blocks * uint64(st.Bsize)
|
||||||
free = st.Bavail * uint64(st.Bsize)
|
free = st.Bavail * uint64(st.Bsize)
|
||||||
return total, free, fs, true
|
return total, free, fs, true
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,13 @@ import (
|
||||||
"runtime"
|
"runtime"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// fsKey uniquely identifies a mounted filesystem (dedupe across scan roots).
|
||||||
|
type fsKey struct {
|
||||||
|
typ int64
|
||||||
|
val0 int32
|
||||||
|
val1 int32
|
||||||
|
}
|
||||||
|
|
||||||
type Snapshot struct {
|
type Snapshot struct {
|
||||||
UptimeSeconds int64
|
UptimeSeconds int64
|
||||||
CPUUsagePercent float64
|
CPUUsagePercent float64
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue