github.com/demonoid81/moby@v0.0.0-20200517203328-62dd8e17c460/builder/builder-next/worker/gc_unix.go (about)

     1  // +build !windows
     2  
     3  package worker
     4  
     5  import (
     6  	"syscall"
     7  )
     8  
     9  func detectDefaultGCCap(root string) int64 {
    10  	var st syscall.Statfs_t
    11  	if err := syscall.Statfs(root, &st); err != nil {
    12  		return defaultCap
    13  	}
    14  	diskSize := int64(st.Bsize) * int64(st.Blocks) // nolint unconvert
    15  	avail := diskSize / 10
    16  	return (avail/(1<<30) + 1) * 1e9 // round up
    17  }