github.com/Heebron/moby@v0.0.0-20221111184709-6eab4f55faf7/daemon/graphdriver/overlay2/mount.go (about)

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