Skip to content
quarry Artifact [b76f813f67]
Login

Artifact [b76f813f67]

Artifact b76f813f67303957301646b08bf663d9305593a8fae1b0902b88fa2f28857887:


//go:build unix

package api

import "syscall"

// statfs is the filesystem under dir: its size and what an unprivileged
// writer may still use, in bytes. ok is false when the path cannot be
// measured, which is not a finding, only an absence.
func statfs(dir string) (total, free uint64, ok bool) {
	var st syscall.Statfs_t
	if err := syscall.Statfs(dir, &st); err != nil {
		return 0, 0, false
	}
	bs := uint64(st.Bsize)
	return uint64(st.Blocks) * bs, uint64(st.Bavail) * bs, true
}