github.com/geofffranks/garden-linux@v0.0.0-20160715111146-26c893169cfa/integration/runner/tmpfs_mounter_linux.go (about) 1 package runner 2 3 import ( 4 "os" 5 "os/exec" 6 "syscall" 7 ) 8 9 func MustMountTmpfs(destination string) { 10 if _, err := os.Stat(destination); os.IsNotExist(err) { 11 must(os.MkdirAll(destination, 0755)) 12 } 13 14 if err := exec.Command("mountpoint", destination).Run(); err != nil { 15 must(syscall.Mount("tmpfs", destination, "tmpfs", 0, "")) 16 } 17 } 18 19 func MustUnmountTmpfs(destination string) { 20 must(syscall.Unmount(destination, 0)) 21 } 22 23 func must(err error) { 24 if err != nil { 25 panic(err) 26 } 27 }