github.com/Prakhar-Agarwal-byte/moby@v0.0.0-20231027092010-a14e3e8ab87e/daemon/graphdriver/overlay2/mount.go (about) 1 //go:build linux 2 3 package overlay2 // import "github.com/Prakhar-Agarwal-byte/moby/daemon/graphdriver/overlay2" 4 5 import ( 6 "runtime" 7 8 "golang.org/x/sys/unix" 9 ) 10 11 func mountFrom(dir, device, target, mType string, flags uintptr, label string) error { 12 chErr := make(chan error, 1) 13 14 go func() { 15 runtime.LockOSThread() 16 // Do not unlock this thread as the thread state cannot be restored 17 // We do not want go to re-use this thread for anything else. 18 19 if err := unix.Unshare(unix.CLONE_FS); err != nil { 20 chErr <- err 21 return 22 } 23 if err := unix.Chdir(dir); err != nil { 24 chErr <- err 25 return 26 } 27 chErr <- unix.Mount(device, target, mType, flags, label) 28 }() 29 return <-chErr 30 }