File: mount.go

package info (click to toggle)
docker.io 27.5.1%2Bdfsg4-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 67,384 kB
  • sloc: sh: 5,847; makefile: 1,146; ansic: 664; python: 162; asm: 133
file content (30 lines) | stat: -rw-r--r-- 679 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
//go:build linux

package overlay2 // import "github.com/docker/docker/daemon/graphdriver/overlay2"

import (
	"runtime"

	"golang.org/x/sys/unix"
)

func mountFrom(dir, device, target, mType string, flags uintptr, label string) error {
	chErr := make(chan error, 1)

	go func() {
		runtime.LockOSThread()
		// Do not unlock this thread as the thread state cannot be restored
		// We do not want go to re-use this thread for anything else.

		if err := unix.Unshare(unix.CLONE_FS); err != nil {
			chErr <- err
			return
		}
		if err := unix.Chdir(dir); err != nil {
			chErr <- err
			return
		}
		chErr <- unix.Mount(device, target, mType, flags, label)
	}()
	return <-chErr
}