16 lines
345 B
Go
16 lines
345 B
Go
//go:build unix
|
|
|
|
package server
|
|
|
|
import "syscall"
|
|
|
|
// freeBytes reports the space available to an unprivileged writer on the
|
|
// filesystem holding path.
|
|
func freeBytes(path string) (int64, bool) {
|
|
var st syscall.Statfs_t
|
|
if err := syscall.Statfs(path, &st); err != nil {
|
|
return 0, false
|
|
}
|
|
return int64(st.Bavail) * int64(st.Bsize), true
|
|
}
|