Forráskód Böngészése

Move mount parsing to separate package.

This moves the platform specific stuff in a separate package and keeps
the `volume` package and the defined interfaces light to import.

Signed-off-by: Brian Goff <cpuguy83@gmail.com>
Brian Goff 7 éve
szülő
commit
6a70fd222b

+ 5 - 4
container/container.go

@@ -37,6 +37,7 @@ import (
 	"github.com/docker/docker/restartmanager"
 	"github.com/docker/docker/restartmanager"
 	"github.com/docker/docker/runconfig"
 	"github.com/docker/docker/runconfig"
 	"github.com/docker/docker/volume"
 	"github.com/docker/docker/volume"
+	volumemounts "github.com/docker/docker/volume/mounts"
 	"github.com/docker/go-connections/nat"
 	"github.com/docker/go-connections/nat"
 	units "github.com/docker/go-units"
 	units "github.com/docker/go-units"
 	"github.com/docker/libnetwork"
 	"github.com/docker/libnetwork"
@@ -94,7 +95,7 @@ type Container struct {
 	RestartCount           int
 	RestartCount           int
 	HasBeenStartedBefore   bool
 	HasBeenStartedBefore   bool
 	HasBeenManuallyStopped bool // used for unless-stopped restart policy
 	HasBeenManuallyStopped bool // used for unless-stopped restart policy
-	MountPoints            map[string]*volume.MountPoint
+	MountPoints            map[string]*volumemounts.MountPoint
 	HostConfig             *containertypes.HostConfig `json:"-"` // do not serialize the host config in the json, otherwise we'll make the container unportable
 	HostConfig             *containertypes.HostConfig `json:"-"` // do not serialize the host config in the json, otherwise we'll make the container unportable
 	ExecCommands           *exec.Store                `json:"-"`
 	ExecCommands           *exec.Store                `json:"-"`
 	DependencyStore        agentexec.DependencyGetter `json:"-"`
 	DependencyStore        agentexec.DependencyGetter `json:"-"`
@@ -128,7 +129,7 @@ func NewBaseContainer(id, root string) *Container {
 		State:         NewState(),
 		State:         NewState(),
 		ExecCommands:  exec.NewStore(),
 		ExecCommands:  exec.NewStore(),
 		Root:          root,
 		Root:          root,
-		MountPoints:   make(map[string]*volume.MountPoint),
+		MountPoints:   make(map[string]*volumemounts.MountPoint),
 		StreamConfig:  stream.NewConfig(),
 		StreamConfig:  stream.NewConfig(),
 		attachContext: &attachContext{},
 		attachContext: &attachContext{},
 	}
 	}
@@ -450,8 +451,8 @@ func (container *Container) AddMountPointWithVolume(destination string, vol volu
 	if operatingSystem == "" {
 	if operatingSystem == "" {
 		operatingSystem = runtime.GOOS
 		operatingSystem = runtime.GOOS
 	}
 	}
-	volumeParser := volume.NewParser(operatingSystem)
-	container.MountPoints[destination] = &volume.MountPoint{
+	volumeParser := volumemounts.NewParser(operatingSystem)
+	container.MountPoints[destination] = &volumemounts.MountPoint{
 		Type:        mounttypes.TypeVolume,
 		Type:        mounttypes.TypeVolume,
 		Name:        vol.Name(),
 		Name:        vol.Name(),
 		Driver:      vol.DriverName(),
 		Driver:      vol.DriverName(),

+ 4 - 3
container/container_unix.go

@@ -15,6 +15,7 @@ import (
 	"github.com/docker/docker/pkg/mount"
 	"github.com/docker/docker/pkg/mount"
 	"github.com/docker/docker/pkg/stringid"
 	"github.com/docker/docker/pkg/stringid"
 	"github.com/docker/docker/volume"
 	"github.com/docker/docker/volume"
+	volumemounts "github.com/docker/docker/volume/mounts"
 	"github.com/opencontainers/selinux/go-selinux/label"
 	"github.com/opencontainers/selinux/go-selinux/label"
 	"github.com/pkg/errors"
 	"github.com/pkg/errors"
 	"github.com/sirupsen/logrus"
 	"github.com/sirupsen/logrus"
@@ -61,7 +62,7 @@ func (container *Container) BuildHostnameFile() error {
 func (container *Container) NetworkMounts() []Mount {
 func (container *Container) NetworkMounts() []Mount {
 	var mounts []Mount
 	var mounts []Mount
 	shared := container.HostConfig.NetworkMode.IsContainer()
 	shared := container.HostConfig.NetworkMode.IsContainer()
-	parser := volume.NewParser(container.OS)
+	parser := volumemounts.NewParser(container.OS)
 	if container.ResolvConfPath != "" {
 	if container.ResolvConfPath != "" {
 		if _, err := os.Stat(container.ResolvConfPath); err != nil {
 		if _, err := os.Stat(container.ResolvConfPath); err != nil {
 			logrus.Warnf("ResolvConfPath set to %q, but can't stat this filename (err = %v); skipping", container.ResolvConfPath, err)
 			logrus.Warnf("ResolvConfPath set to %q, but can't stat this filename (err = %v); skipping", container.ResolvConfPath, err)
@@ -198,7 +199,7 @@ func (container *Container) UnmountIpcMount(unmount func(pth string) error) erro
 // IpcMounts returns the list of IPC mounts
 // IpcMounts returns the list of IPC mounts
 func (container *Container) IpcMounts() []Mount {
 func (container *Container) IpcMounts() []Mount {
 	var mounts []Mount
 	var mounts []Mount
-	parser := volume.NewParser(container.OS)
+	parser := volumemounts.NewParser(container.OS)
 
 
 	if container.HasMountFor("/dev/shm") {
 	if container.HasMountFor("/dev/shm") {
 		return mounts
 		return mounts
@@ -402,7 +403,7 @@ func copyExistingContents(source, destination string) error {
 
 
 // TmpfsMounts returns the list of tmpfs mounts
 // TmpfsMounts returns the list of tmpfs mounts
 func (container *Container) TmpfsMounts() ([]Mount, error) {
 func (container *Container) TmpfsMounts() ([]Mount, error) {
-	parser := volume.NewParser(container.OS)
+	parser := volumemounts.NewParser(container.OS)
 	var mounts []Mount
 	var mounts []Mount
 	for dest, data := range container.HostConfig.Tmpfs {
 	for dest, data := range container.HostConfig.Tmpfs {
 		mounts = append(mounts, Mount{
 		mounts = append(mounts, Mount{

+ 2 - 2
daemon/archive_unix.go

@@ -4,7 +4,7 @@ package daemon // import "github.com/docker/docker/daemon"
 
 
 import (
 import (
 	"github.com/docker/docker/container"
 	"github.com/docker/docker/container"
-	"github.com/docker/docker/volume"
+	volumemounts "github.com/docker/docker/volume/mounts"
 )
 )
 
 
 // checkIfPathIsInAVolume checks if the path is in a volume. If it is, it
 // checkIfPathIsInAVolume checks if the path is in a volume. If it is, it
@@ -12,7 +12,7 @@ import (
 // cannot be configured with a read-only rootfs.
 // cannot be configured with a read-only rootfs.
 func checkIfPathIsInAVolume(container *container.Container, absPath string) (bool, error) {
 func checkIfPathIsInAVolume(container *container.Container, absPath string) (bool, error) {
 	var toVolume bool
 	var toVolume bool
-	parser := volume.NewParser(container.OS)
+	parser := volumemounts.NewParser(container.OS)
 	for _, mnt := range container.MountPoints {
 	for _, mnt := range container.MountPoints {
 		if toVolume = parser.HasResource(mnt, absPath); toVolume {
 		if toVolume = parser.HasResource(mnt, absPath); toVolume {
 			if mnt.RW {
 			if mnt.RW {

+ 2 - 2
daemon/container.go

@@ -20,7 +20,7 @@ import (
 	"github.com/docker/docker/pkg/system"
 	"github.com/docker/docker/pkg/system"
 	"github.com/docker/docker/pkg/truncindex"
 	"github.com/docker/docker/pkg/truncindex"
 	"github.com/docker/docker/runconfig"
 	"github.com/docker/docker/runconfig"
-	"github.com/docker/docker/volume"
+	volumemounts "github.com/docker/docker/volume/mounts"
 	"github.com/docker/go-connections/nat"
 	"github.com/docker/go-connections/nat"
 	"github.com/opencontainers/selinux/go-selinux/label"
 	"github.com/opencontainers/selinux/go-selinux/label"
 	"github.com/pkg/errors"
 	"github.com/pkg/errors"
@@ -296,7 +296,7 @@ func (daemon *Daemon) verifyContainerSettings(platform string, hostConfig *conta
 	}
 	}
 
 
 	// Validate mounts; check if host directories still exist
 	// Validate mounts; check if host directories still exist
-	parser := volume.NewParser(platform)
+	parser := volumemounts.NewParser(platform)
 	for _, cfg := range hostConfig.Mounts {
 	for _, cfg := range hostConfig.Mounts {
 		if err := parser.ValidateMountConfig(&cfg); err != nil {
 		if err := parser.ValidateMountConfig(&cfg); err != nil {
 			return nil, err
 			return nil, err

+ 2 - 2
daemon/create_windows.go

@@ -7,7 +7,7 @@ import (
 	containertypes "github.com/docker/docker/api/types/container"
 	containertypes "github.com/docker/docker/api/types/container"
 	"github.com/docker/docker/container"
 	"github.com/docker/docker/container"
 	"github.com/docker/docker/pkg/stringid"
 	"github.com/docker/docker/pkg/stringid"
-	"github.com/docker/docker/volume"
+	volumemounts "github.com/docker/docker/volume/mounts"
 )
 )
 
 
 // createContainerOSSpecificSettings performs host-OS specific container create functionality
 // createContainerOSSpecificSettings performs host-OS specific container create functionality
@@ -26,7 +26,7 @@ func (daemon *Daemon) createContainerOSSpecificSettings(container *container.Con
 		}
 		}
 		hostConfig.Isolation = "hyperv"
 		hostConfig.Isolation = "hyperv"
 	}
 	}
-	parser := volume.NewParser(container.OS)
+	parser := volumemounts.NewParser(container.OS)
 	for spec := range config.Volumes {
 	for spec := range config.Volumes {
 
 
 		mp, err := parser.ParseMountRaw(spec, hostConfig.VolumeDriver)
 		mp, err := parser.ParseMountRaw(spec, hostConfig.VolumeDriver)

+ 2 - 2
daemon/daemon_unix.go

@@ -33,7 +33,7 @@ import (
 	"github.com/docker/docker/pkg/parsers/kernel"
 	"github.com/docker/docker/pkg/parsers/kernel"
 	"github.com/docker/docker/pkg/sysinfo"
 	"github.com/docker/docker/pkg/sysinfo"
 	"github.com/docker/docker/runconfig"
 	"github.com/docker/docker/runconfig"
-	"github.com/docker/docker/volume"
+	volumemounts "github.com/docker/docker/volume/mounts"
 	"github.com/docker/libnetwork"
 	"github.com/docker/libnetwork"
 	nwconfig "github.com/docker/libnetwork/config"
 	nwconfig "github.com/docker/libnetwork/config"
 	"github.com/docker/libnetwork/drivers/bridge"
 	"github.com/docker/libnetwork/drivers/bridge"
@@ -626,7 +626,7 @@ func verifyPlatformContainerSettings(daemon *Daemon, hostConfig *containertypes.
 		return warnings, fmt.Errorf("Unknown runtime specified %s", hostConfig.Runtime)
 		return warnings, fmt.Errorf("Unknown runtime specified %s", hostConfig.Runtime)
 	}
 	}
 
 
-	parser := volume.NewParser(runtime.GOOS)
+	parser := volumemounts.NewParser(runtime.GOOS)
 	for dest := range hostConfig.Tmpfs {
 	for dest := range hostConfig.Tmpfs {
 		if err := parser.ValidateTmpfsMountDestination(dest); err != nil {
 		if err := parser.ValidateTmpfsMountDestination(dest); err != nil {
 			return warnings, err
 			return warnings, err

+ 2 - 2
daemon/oci_linux.go

@@ -18,7 +18,7 @@ import (
 	"github.com/docker/docker/oci"
 	"github.com/docker/docker/oci"
 	"github.com/docker/docker/pkg/idtools"
 	"github.com/docker/docker/pkg/idtools"
 	"github.com/docker/docker/pkg/mount"
 	"github.com/docker/docker/pkg/mount"
-	"github.com/docker/docker/volume"
+	volumemounts "github.com/docker/docker/volume/mounts"
 	"github.com/opencontainers/runc/libcontainer/apparmor"
 	"github.com/opencontainers/runc/libcontainer/apparmor"
 	"github.com/opencontainers/runc/libcontainer/cgroups"
 	"github.com/opencontainers/runc/libcontainer/cgroups"
 	"github.com/opencontainers/runc/libcontainer/devices"
 	"github.com/opencontainers/runc/libcontainer/devices"
@@ -580,7 +580,7 @@ func setMounts(daemon *Daemon, s *specs.Spec, c *container.Container, mounts []c
 
 
 		if m.Source == "tmpfs" {
 		if m.Source == "tmpfs" {
 			data := m.Data
 			data := m.Data
-			parser := volume.NewParser("linux")
+			parser := volumemounts.NewParser("linux")
 			options := []string{"noexec", "nosuid", "nodev", string(parser.DefaultPropagationMode())}
 			options := []string{"noexec", "nosuid", "nodev", string(parser.DefaultPropagationMode())}
 			if data != "" {
 			if data != "" {
 				options = append(options, strings.Split(data, ",")...)
 				options = append(options, strings.Split(data, ",")...)

+ 10 - 8
daemon/volumes.go

@@ -14,6 +14,7 @@ import (
 	"github.com/docker/docker/container"
 	"github.com/docker/docker/container"
 	"github.com/docker/docker/errdefs"
 	"github.com/docker/docker/errdefs"
 	"github.com/docker/docker/volume"
 	"github.com/docker/docker/volume"
+	volumemounts "github.com/docker/docker/volume/mounts"
 	"github.com/pkg/errors"
 	"github.com/pkg/errors"
 	"github.com/sirupsen/logrus"
 	"github.com/sirupsen/logrus"
 )
 )
@@ -74,8 +75,9 @@ func (m mounts) parts(i int) int {
 // 4. Cleanup old volumes that are about to be reassigned.
 // 4. Cleanup old volumes that are about to be reassigned.
 func (daemon *Daemon) registerMountPoints(container *container.Container, hostConfig *containertypes.HostConfig) (retErr error) {
 func (daemon *Daemon) registerMountPoints(container *container.Container, hostConfig *containertypes.HostConfig) (retErr error) {
 	binds := map[string]bool{}
 	binds := map[string]bool{}
-	mountPoints := map[string]*volume.MountPoint{}
-	parser := volume.NewParser(container.OS)
+	mountPoints := map[string]*volumemounts.MountPoint{}
+	parser := volumemounts.NewParser(container.OS)
+
 	defer func() {
 	defer func() {
 		// clean up the container mountpoints once return with error
 		// clean up the container mountpoints once return with error
 		if retErr != nil {
 		if retErr != nil {
@@ -115,7 +117,7 @@ func (daemon *Daemon) registerMountPoints(container *container.Container, hostCo
 		}
 		}
 
 
 		for _, m := range c.MountPoints {
 		for _, m := range c.MountPoints {
-			cp := &volume.MountPoint{
+			cp := &volumemounts.MountPoint{
 				Type:        m.Type,
 				Type:        m.Type,
 				Name:        m.Name,
 				Name:        m.Name,
 				Source:      m.Source,
 				Source:      m.Source,
@@ -250,7 +252,7 @@ func (daemon *Daemon) registerMountPoints(container *container.Container, hostCo
 
 
 // lazyInitializeVolume initializes a mountpoint's volume if needed.
 // lazyInitializeVolume initializes a mountpoint's volume if needed.
 // This happens after a daemon restart.
 // This happens after a daemon restart.
-func (daemon *Daemon) lazyInitializeVolume(containerID string, m *volume.MountPoint) error {
+func (daemon *Daemon) lazyInitializeVolume(containerID string, m *volumemounts.MountPoint) error {
 	if len(m.Driver) > 0 && m.Volume == nil {
 	if len(m.Driver) > 0 && m.Volume == nil {
 		v, err := daemon.volumes.GetWithRef(m.Name, m.Driver, containerID)
 		v, err := daemon.volumes.GetWithRef(m.Name, m.Driver, containerID)
 		if err != nil {
 		if err != nil {
@@ -270,7 +272,7 @@ func (daemon *Daemon) backportMountSpec(container *container.Container) {
 	container.Lock()
 	container.Lock()
 	defer container.Unlock()
 	defer container.Unlock()
 
 
-	parser := volume.NewParser(container.OS)
+	parser := volumemounts.NewParser(container.OS)
 
 
 	maybeUpdate := make(map[string]bool)
 	maybeUpdate := make(map[string]bool)
 	for _, mp := range container.MountPoints {
 	for _, mp := range container.MountPoints {
@@ -288,7 +290,7 @@ func (daemon *Daemon) backportMountSpec(container *container.Container) {
 		mountSpecs[m.Target] = true
 		mountSpecs[m.Target] = true
 	}
 	}
 
 
-	binds := make(map[string]*volume.MountPoint, len(container.HostConfig.Binds))
+	binds := make(map[string]*volumemounts.MountPoint, len(container.HostConfig.Binds))
 	for _, rawSpec := range container.HostConfig.Binds {
 	for _, rawSpec := range container.HostConfig.Binds {
 		mp, err := parser.ParseMountRaw(rawSpec, container.HostConfig.VolumeDriver)
 		mp, err := parser.ParseMountRaw(rawSpec, container.HostConfig.VolumeDriver)
 		if err != nil {
 		if err != nil {
@@ -298,7 +300,7 @@ func (daemon *Daemon) backportMountSpec(container *container.Container) {
 		binds[mp.Destination] = mp
 		binds[mp.Destination] = mp
 	}
 	}
 
 
-	volumesFrom := make(map[string]volume.MountPoint)
+	volumesFrom := make(map[string]volumemounts.MountPoint)
 	for _, fromSpec := range container.HostConfig.VolumesFrom {
 	for _, fromSpec := range container.HostConfig.VolumesFrom {
 		from, _, err := parser.ParseVolumesFrom(fromSpec)
 		from, _, err := parser.ParseVolumesFrom(fromSpec)
 		if err != nil {
 		if err != nil {
@@ -321,7 +323,7 @@ func (daemon *Daemon) backportMountSpec(container *container.Container) {
 		fromC.Unlock()
 		fromC.Unlock()
 	}
 	}
 
 
-	needsUpdate := func(containerMount, other *volume.MountPoint) bool {
+	needsUpdate := func(containerMount, other *volumemounts.MountPoint) bool {
 		if containerMount.Type != other.Type || !reflect.DeepEqual(containerMount.Spec, other.Spec) {
 		if containerMount.Type != other.Type || !reflect.DeepEqual(containerMount.Spec, other.Spec) {
 			return true
 			return true
 		}
 		}

+ 2 - 2
daemon/volumes_unit_test.go

@@ -4,7 +4,7 @@ import (
 	"runtime"
 	"runtime"
 	"testing"
 	"testing"
 
 
-	"github.com/docker/docker/volume"
+	volumemounts "github.com/docker/docker/volume/mounts"
 )
 )
 
 
 func TestParseVolumesFrom(t *testing.T) {
 func TestParseVolumesFrom(t *testing.T) {
@@ -21,7 +21,7 @@ func TestParseVolumesFrom(t *testing.T) {
 		{"foobar:baz", "", "", true},
 		{"foobar:baz", "", "", true},
 	}
 	}
 
 
-	parser := volume.NewParser(runtime.GOOS)
+	parser := volumemounts.NewParser(runtime.GOOS)
 
 
 	for _, c := range cases {
 	for _, c := range cases {
 		id, mode, err := parser.ParseVolumesFrom(c.spec)
 		id, mode, err := parser.ParseVolumesFrom(c.spec)

+ 3 - 3
daemon/volumes_unix.go

@@ -12,7 +12,7 @@ import (
 	"github.com/docker/docker/container"
 	"github.com/docker/docker/container"
 	"github.com/docker/docker/pkg/fileutils"
 	"github.com/docker/docker/pkg/fileutils"
 	"github.com/docker/docker/pkg/mount"
 	"github.com/docker/docker/pkg/mount"
-	"github.com/docker/docker/volume"
+	volumemounts "github.com/docker/docker/volume/mounts"
 )
 )
 
 
 // setupMounts iterates through each of the mount points for a container and
 // setupMounts iterates through each of the mount points for a container and
@@ -40,7 +40,7 @@ func (daemon *Daemon) setupMounts(c *container.Container) ([]container.Mount, er
 		// mount the socket the daemon is listening on. During daemon shutdown, the socket
 		// mount the socket the daemon is listening on. During daemon shutdown, the socket
 		// (/var/run/docker.sock by default) doesn't exist anymore causing the call to m.Setup to
 		// (/var/run/docker.sock by default) doesn't exist anymore causing the call to m.Setup to
 		// create at directory instead. This in turn will prevent the daemon to restart.
 		// create at directory instead. This in turn will prevent the daemon to restart.
-		checkfunc := func(m *volume.MountPoint) error {
+		checkfunc := func(m *volumemounts.MountPoint) error {
 			if _, exist := daemon.hosts[m.Source]; exist && daemon.IsShuttingDown() {
 			if _, exist := daemon.hosts[m.Source]; exist && daemon.IsShuttingDown() {
 				return fmt.Errorf("Could not mount %q to container while the daemon is shutting down", m.Source)
 				return fmt.Errorf("Could not mount %q to container while the daemon is shutting down", m.Source)
 			}
 			}
@@ -102,7 +102,7 @@ func sortMounts(m []container.Mount) []container.Mount {
 // setBindModeIfNull is platform specific processing to ensure the
 // setBindModeIfNull is platform specific processing to ensure the
 // shared mode is set to 'z' if it is null. This is called in the case
 // shared mode is set to 'z' if it is null. This is called in the case
 // of processing a named volume and not a typical bind.
 // of processing a named volume and not a typical bind.
-func setBindModeIfNull(bind *volume.MountPoint) {
+func setBindModeIfNull(bind *volumemounts.MountPoint) {
 	if bind.Mode == "" {
 	if bind.Mode == "" {
 		bind.Mode = "z"
 		bind.Mode = "z"
 	}
 	}

+ 14 - 14
daemon/volumes_unix_test.go

@@ -11,7 +11,7 @@ import (
 	containertypes "github.com/docker/docker/api/types/container"
 	containertypes "github.com/docker/docker/api/types/container"
 	mounttypes "github.com/docker/docker/api/types/mount"
 	mounttypes "github.com/docker/docker/api/types/mount"
 	"github.com/docker/docker/container"
 	"github.com/docker/docker/container"
-	"github.com/docker/docker/volume"
+	volumemounts "github.com/docker/docker/volume/mounts"
 )
 )
 
 
 func TestBackportMountSpec(t *testing.T) {
 func TestBackportMountSpec(t *testing.T) {
@@ -19,7 +19,7 @@ func TestBackportMountSpec(t *testing.T) {
 
 
 	c := &container.Container{
 	c := &container.Container{
 		State: &container.State{},
 		State: &container.State{},
-		MountPoints: map[string]*volume.MountPoint{
+		MountPoints: map[string]*volumemounts.MountPoint{
 			"/apple":      {Destination: "/apple", Source: "/var/lib/docker/volumes/12345678", Name: "12345678", RW: true, CopyData: true}, // anonymous volume
 			"/apple":      {Destination: "/apple", Source: "/var/lib/docker/volumes/12345678", Name: "12345678", RW: true, CopyData: true}, // anonymous volume
 			"/banana":     {Destination: "/banana", Source: "/var/lib/docker/volumes/data", Name: "data", RW: true, CopyData: true},        // named volume
 			"/banana":     {Destination: "/banana", Source: "/var/lib/docker/volumes/data", Name: "data", RW: true, CopyData: true},        // named volume
 			"/cherry":     {Destination: "/cherry", Source: "/var/lib/docker/volumes/data", Name: "data", CopyData: true},                  // RO named volume
 			"/cherry":     {Destination: "/cherry", Source: "/var/lib/docker/volumes/data", Name: "data", CopyData: true},                  // RO named volume
@@ -73,7 +73,7 @@ func TestBackportMountSpec(t *testing.T) {
 	d.containers.Add("1", &container.Container{
 	d.containers.Add("1", &container.Container{
 		State: &container.State{},
 		State: &container.State{},
 		ID:    "1",
 		ID:    "1",
-		MountPoints: map[string]*volume.MountPoint{
+		MountPoints: map[string]*volumemounts.MountPoint{
 			"/kumquat": {Destination: "/kumquat", Name: "data", RW: false, CopyData: true},
 			"/kumquat": {Destination: "/kumquat", Name: "data", RW: false, CopyData: true},
 		},
 		},
 		HostConfig: &containertypes.HostConfig{
 		HostConfig: &containertypes.HostConfig{
@@ -84,11 +84,11 @@ func TestBackportMountSpec(t *testing.T) {
 	})
 	})
 
 
 	type expected struct {
 	type expected struct {
-		mp      *volume.MountPoint
+		mp      *volumemounts.MountPoint
 		comment string
 		comment string
 	}
 	}
 
 
-	pretty := func(mp *volume.MountPoint) string {
+	pretty := func(mp *volumemounts.MountPoint) string {
 		b, err := json.MarshalIndent(mp, "\t", "    ")
 		b, err := json.MarshalIndent(mp, "\t", "    ")
 		if err != nil {
 		if err != nil {
 			return fmt.Sprintf("%#v", mp)
 			return fmt.Sprintf("%#v", mp)
@@ -98,7 +98,7 @@ func TestBackportMountSpec(t *testing.T) {
 
 
 	for _, x := range []expected{
 	for _, x := range []expected{
 		{
 		{
-			mp: &volume.MountPoint{
+			mp: &volumemounts.MountPoint{
 				Type:        mounttypes.TypeVolume,
 				Type:        mounttypes.TypeVolume,
 				Destination: "/apple",
 				Destination: "/apple",
 				RW:          true,
 				RW:          true,
@@ -114,7 +114,7 @@ func TestBackportMountSpec(t *testing.T) {
 			comment: "anonymous volume",
 			comment: "anonymous volume",
 		},
 		},
 		{
 		{
-			mp: &volume.MountPoint{
+			mp: &volumemounts.MountPoint{
 				Type:        mounttypes.TypeVolume,
 				Type:        mounttypes.TypeVolume,
 				Destination: "/banana",
 				Destination: "/banana",
 				RW:          true,
 				RW:          true,
@@ -130,7 +130,7 @@ func TestBackportMountSpec(t *testing.T) {
 			comment: "named volume",
 			comment: "named volume",
 		},
 		},
 		{
 		{
-			mp: &volume.MountPoint{
+			mp: &volumemounts.MountPoint{
 				Type:        mounttypes.TypeVolume,
 				Type:        mounttypes.TypeVolume,
 				Destination: "/cherry",
 				Destination: "/cherry",
 				Name:        "data",
 				Name:        "data",
@@ -146,7 +146,7 @@ func TestBackportMountSpec(t *testing.T) {
 			comment: "read-only named volume",
 			comment: "read-only named volume",
 		},
 		},
 		{
 		{
-			mp: &volume.MountPoint{
+			mp: &volumemounts.MountPoint{
 				Type:        mounttypes.TypeVolume,
 				Type:        mounttypes.TypeVolume,
 				Destination: "/dates",
 				Destination: "/dates",
 				Name:        "data",
 				Name:        "data",
@@ -162,7 +162,7 @@ func TestBackportMountSpec(t *testing.T) {
 			comment: "named volume with nocopy",
 			comment: "named volume with nocopy",
 		},
 		},
 		{
 		{
-			mp: &volume.MountPoint{
+			mp: &volumemounts.MountPoint{
 				Type:        mounttypes.TypeVolume,
 				Type:        mounttypes.TypeVolume,
 				Destination: "/elderberry",
 				Destination: "/elderberry",
 				Name:        "data",
 				Name:        "data",
@@ -178,7 +178,7 @@ func TestBackportMountSpec(t *testing.T) {
 			comment: "masks an anonymous volume",
 			comment: "masks an anonymous volume",
 		},
 		},
 		{
 		{
-			mp: &volume.MountPoint{
+			mp: &volumemounts.MountPoint{
 				Type:        mounttypes.TypeBind,
 				Type:        mounttypes.TypeBind,
 				Destination: "/fig",
 				Destination: "/fig",
 				Source:      "/data",
 				Source:      "/data",
@@ -192,7 +192,7 @@ func TestBackportMountSpec(t *testing.T) {
 			comment: "bind mount with read/write",
 			comment: "bind mount with read/write",
 		},
 		},
 		{
 		{
-			mp: &volume.MountPoint{
+			mp: &volumemounts.MountPoint{
 				Type:        mounttypes.TypeBind,
 				Type:        mounttypes.TypeBind,
 				Destination: "/guava",
 				Destination: "/guava",
 				Source:      "/data",
 				Source:      "/data",
@@ -209,7 +209,7 @@ func TestBackportMountSpec(t *testing.T) {
 			comment: "bind mount with read/write + shared propagation",
 			comment: "bind mount with read/write + shared propagation",
 		},
 		},
 		{
 		{
-			mp: &volume.MountPoint{
+			mp: &volumemounts.MountPoint{
 				Type:        mounttypes.TypeVolume,
 				Type:        mounttypes.TypeVolume,
 				Destination: "/honeydew",
 				Destination: "/honeydew",
 				Source:      "/var/lib/docker/volumes/data",
 				Source:      "/var/lib/docker/volumes/data",
@@ -229,7 +229,7 @@ func TestBackportMountSpec(t *testing.T) {
 			comment: "volume defined in mounts API",
 			comment: "volume defined in mounts API",
 		},
 		},
 		{
 		{
-			mp: &volume.MountPoint{
+			mp: &volumemounts.MountPoint{
 				Type:        mounttypes.TypeVolume,
 				Type:        mounttypes.TypeVolume,
 				Destination: "/kumquat",
 				Destination: "/kumquat",
 				Source:      "/var/lib/docker/volumes/data",
 				Source:      "/var/lib/docker/volumes/data",

+ 3 - 3
daemon/volumes_windows.go

@@ -6,7 +6,7 @@ import (
 	"github.com/docker/docker/api/types/mount"
 	"github.com/docker/docker/api/types/mount"
 	"github.com/docker/docker/container"
 	"github.com/docker/docker/container"
 	"github.com/docker/docker/pkg/idtools"
 	"github.com/docker/docker/pkg/idtools"
-	"github.com/docker/docker/volume"
+	volumemounts "github.com/docker/docker/volume/mounts"
 )
 )
 
 
 // setupMounts configures the mount points for a container by appending each
 // setupMounts configures the mount points for a container by appending each
@@ -20,7 +20,7 @@ import (
 
 
 func (daemon *Daemon) setupMounts(c *container.Container) ([]container.Mount, error) {
 func (daemon *Daemon) setupMounts(c *container.Container) ([]container.Mount, error) {
 	var mnts []container.Mount
 	var mnts []container.Mount
-	for _, mount := range c.MountPoints { // type is volume.MountPoint
+	for _, mount := range c.MountPoints { // type is volumemounts.MountPoint
 		if err := daemon.lazyInitializeVolume(c.ID, mount); err != nil {
 		if err := daemon.lazyInitializeVolume(c.ID, mount); err != nil {
 			return nil, err
 			return nil, err
 		}
 		}
@@ -42,7 +42,7 @@ func (daemon *Daemon) setupMounts(c *container.Container) ([]container.Mount, er
 
 
 // setBindModeIfNull is platform specific processing which is a no-op on
 // setBindModeIfNull is platform specific processing which is a no-op on
 // Windows.
 // Windows.
-func setBindModeIfNull(bind *volume.MountPoint) {
+func setBindModeIfNull(bind *volumemounts.MountPoint) {
 	return
 	return
 }
 }
 
 

+ 1 - 1
volume/lcow_parser.go → volume/mounts/lcow_parser.go

@@ -1,4 +1,4 @@
-package volume // import "github.com/docker/docker/volume"
+package mounts // import "github.com/docker/docker/volume/mounts"
 
 
 import (
 import (
 	"errors"
 	"errors"

+ 3 - 2
volume/linux_parser.go → volume/mounts/linux_parser.go

@@ -1,4 +1,4 @@
-package volume // import "github.com/docker/docker/volume"
+package mounts // import "github.com/docker/docker/volume/mounts"
 
 
 import (
 import (
 	"errors"
 	"errors"
@@ -9,6 +9,7 @@ import (
 
 
 	"github.com/docker/docker/api/types/mount"
 	"github.com/docker/docker/api/types/mount"
 	"github.com/docker/docker/pkg/stringid"
 	"github.com/docker/docker/pkg/stringid"
+	"github.com/docker/docker/volume"
 )
 )
 
 
 type linuxParser struct {
 type linuxParser struct {
@@ -405,7 +406,7 @@ func (p *linuxParser) ValidateVolumeName(name string) error {
 }
 }
 
 
 func (p *linuxParser) IsBackwardCompatible(m *MountPoint) bool {
 func (p *linuxParser) IsBackwardCompatible(m *MountPoint) bool {
-	return len(m.Source) > 0 || m.Driver == DefaultDriverName
+	return len(m.Source) > 0 || m.Driver == volume.DefaultDriverName
 }
 }
 
 
 func (p *linuxParser) ValidateTmpfsMountDestination(dest string) error {
 func (p *linuxParser) ValidateTmpfsMountDestination(dest string) error {

+ 170 - 0
volume/mounts/mounts.go

@@ -0,0 +1,170 @@
+package mounts // import "github.com/docker/docker/volume/mounts"
+
+import (
+	"fmt"
+	"os"
+	"path/filepath"
+	"syscall"
+
+	mounttypes "github.com/docker/docker/api/types/mount"
+	"github.com/docker/docker/pkg/idtools"
+	"github.com/docker/docker/pkg/stringid"
+	"github.com/docker/docker/volume"
+	"github.com/opencontainers/selinux/go-selinux/label"
+	"github.com/pkg/errors"
+)
+
+// MountPoint is the intersection point between a volume and a container. It
+// specifies which volume is to be used and where inside a container it should
+// be mounted.
+//
+// Note that this type is embedded in `container.Container` object and persisted to disk.
+// Changes to this struct need to by synced with on disk state.
+type MountPoint struct {
+	// Source is the source path of the mount.
+	// E.g. `mount --bind /foo /bar`, `/foo` is the `Source`.
+	Source string
+	// Destination is the path relative to the container root (`/`) to the mount point
+	// It is where the `Source` is mounted to
+	Destination string
+	// RW is set to true when the mountpoint should be mounted as read-write
+	RW bool
+	// Name is the name reference to the underlying data defined by `Source`
+	// e.g., the volume name
+	Name string
+	// Driver is the volume driver used to create the volume (if it is a volume)
+	Driver string
+	// Type of mount to use, see `Type<foo>` definitions in github.com/docker/docker/api/types/mount
+	Type mounttypes.Type `json:",omitempty"`
+	// Volume is the volume providing data to this mountpoint.
+	// This is nil unless `Type` is set to `TypeVolume`
+	Volume volume.Volume `json:"-"`
+
+	// Mode is the comma separated list of options supplied by the user when creating
+	// the bind/volume mount.
+	// Note Mode is not used on Windows
+	Mode string `json:"Relabel,omitempty"` // Originally field was `Relabel`"
+
+	// Propagation describes how the mounts are propagated from the host into the
+	// mount point, and vice-versa.
+	// See https://www.kernel.org/doc/Documentation/filesystems/sharedsubtree.txt
+	// Note Propagation is not used on Windows
+	Propagation mounttypes.Propagation `json:",omitempty"` // Mount propagation string
+
+	// Specifies if data should be copied from the container before the first mount
+	// Use a pointer here so we can tell if the user set this value explicitly
+	// This allows us to error out when the user explicitly enabled copy but we can't copy due to the volume being populated
+	CopyData bool `json:"-"`
+	// ID is the opaque ID used to pass to the volume driver.
+	// This should be set by calls to `Mount` and unset by calls to `Unmount`
+	ID string `json:",omitempty"`
+
+	// Sepc is a copy of the API request that created this mount.
+	Spec mounttypes.Mount
+
+	// Track usage of this mountpoint
+	// Specifically needed for containers which are running and calls to `docker cp`
+	// because both these actions require mounting the volumes.
+	active int
+}
+
+// Cleanup frees resources used by the mountpoint
+func (m *MountPoint) Cleanup() error {
+	if m.Volume == nil || m.ID == "" {
+		return nil
+	}
+
+	if err := m.Volume.Unmount(m.ID); err != nil {
+		return errors.Wrapf(err, "error unmounting volume %s", m.Volume.Name())
+	}
+
+	m.active--
+	if m.active == 0 {
+		m.ID = ""
+	}
+	return nil
+}
+
+// Setup sets up a mount point by either mounting the volume if it is
+// configured, or creating the source directory if supplied.
+// The, optional, checkFun parameter allows doing additional checking
+// before creating the source directory on the host.
+func (m *MountPoint) Setup(mountLabel string, rootIDs idtools.IDPair, checkFun func(m *MountPoint) error) (path string, err error) {
+	defer func() {
+		if err != nil || !label.RelabelNeeded(m.Mode) {
+			return
+		}
+
+		var sourcePath string
+		sourcePath, err = filepath.EvalSymlinks(m.Source)
+		if err != nil {
+			path = ""
+			err = errors.Wrapf(err, "error evaluating symlinks from mount source %q", m.Source)
+			return
+		}
+		err = label.Relabel(sourcePath, mountLabel, label.IsShared(m.Mode))
+		if err == syscall.ENOTSUP {
+			err = nil
+		}
+		if err != nil {
+			path = ""
+			err = errors.Wrapf(err, "error setting label on mount source '%s'", sourcePath)
+		}
+	}()
+
+	if m.Volume != nil {
+		id := m.ID
+		if id == "" {
+			id = stringid.GenerateNonCryptoID()
+		}
+		path, err := m.Volume.Mount(id)
+		if err != nil {
+			return "", errors.Wrapf(err, "error while mounting volume '%s'", m.Source)
+		}
+
+		m.ID = id
+		m.active++
+		return path, nil
+	}
+
+	if len(m.Source) == 0 {
+		return "", fmt.Errorf("Unable to setup mount point, neither source nor volume defined")
+	}
+
+	if m.Type == mounttypes.TypeBind {
+		// Before creating the source directory on the host, invoke checkFun if it's not nil. One of
+		// the use case is to forbid creating the daemon socket as a directory if the daemon is in
+		// the process of shutting down.
+		if checkFun != nil {
+			if err := checkFun(m); err != nil {
+				return "", err
+			}
+		}
+		// idtools.MkdirAllNewAs() produces an error if m.Source exists and is a file (not a directory)
+		// also, makes sure that if the directory is created, the correct remapped rootUID/rootGID will own it
+		if err := idtools.MkdirAllAndChownNew(m.Source, 0755, rootIDs); err != nil {
+			if perr, ok := err.(*os.PathError); ok {
+				if perr.Err != syscall.ENOTDIR {
+					return "", errors.Wrapf(err, "error while creating mount source path '%s'", m.Source)
+				}
+			}
+		}
+	}
+	return m.Source, nil
+}
+
+// Path returns the path of a volume in a mount point.
+func (m *MountPoint) Path() string {
+	if m.Volume != nil {
+		return m.Volume.Path()
+	}
+	return m.Source
+}
+
+func errInvalidMode(mode string) error {
+	return errors.Errorf("invalid mode: %v", mode)
+}
+
+func errInvalidSpec(spec string) error {
+	return errors.Errorf("invalid volume specification: '%s'", spec)
+}

+ 1 - 1
volume/parser.go → volume/mounts/parser.go

@@ -1,4 +1,4 @@
-package volume // import "github.com/docker/docker/volume"
+package mounts // import "github.com/docker/docker/volume/mounts"
 
 
 import (
 import (
 	"errors"
 	"errors"

+ 1 - 1
volume/volume_test.go → volume/mounts/parser_test.go

@@ -1,4 +1,4 @@
-package volume // import "github.com/docker/docker/volume"
+package mounts // import "github.com/docker/docker/volume/mounts"
 
 
 import (
 import (
 	"io/ioutil"
 	"io/ioutil"

+ 1 - 1
volume/validate.go → volume/mounts/validate.go

@@ -1,4 +1,4 @@
-package volume // import "github.com/docker/docker/volume"
+package mounts // import "github.com/docker/docker/volume/mounts"
 
 
 import (
 import (
 	"fmt"
 	"fmt"

+ 1 - 1
volume/validate_test.go → volume/mounts/validate_test.go

@@ -1,4 +1,4 @@
-package volume // import "github.com/docker/docker/volume"
+package mounts // import "github.com/docker/docker/volume/mounts"
 
 
 import (
 import (
 	"errors"
 	"errors"

+ 1 - 1
volume/validate_unix_test.go → volume/mounts/validate_unix_test.go

@@ -1,6 +1,6 @@
 // +build !windows
 // +build !windows
 
 
-package volume // import "github.com/docker/docker/volume"
+package mounts // import "github.com/docker/docker/volume/mounts"
 
 
 var (
 var (
 	testDestinationPath = "/foo"
 	testDestinationPath = "/foo"

+ 1 - 1
volume/validate_windows_test.go → volume/mounts/validate_windows_test.go

@@ -1,4 +1,4 @@
-package volume // import "github.com/docker/docker/volume"
+package mounts // import "github.com/docker/docker/volume/mounts"
 
 
 var (
 var (
 	testDestinationPath = `c:\foo`
 	testDestinationPath = `c:\foo`

+ 1 - 1
volume/volume_copy.go → volume/mounts/volume_copy.go

@@ -1,4 +1,4 @@
-package volume // import "github.com/docker/docker/volume"
+package mounts // import "github.com/docker/docker/volume/mounts"
 
 
 import "strings"
 import "strings"
 
 

+ 1 - 1
volume/volume_unix.go → volume/mounts/volume_unix.go

@@ -1,6 +1,6 @@
 // +build linux freebsd darwin
 // +build linux freebsd darwin
 
 
-package volume // import "github.com/docker/docker/volume"
+package mounts // import "github.com/docker/docker/volume/mounts"
 
 
 import (
 import (
 	"fmt"
 	"fmt"

+ 1 - 1
volume/volume_windows.go → volume/mounts/volume_windows.go

@@ -1,4 +1,4 @@
-package volume // import "github.com/docker/docker/volume"
+package mounts // import "github.com/docker/docker/volume/mounts"
 
 
 func (p *windowsParser) HasResource(m *MountPoint, absolutePath string) bool {
 func (p *windowsParser) HasResource(m *MountPoint, absolutePath string) bool {
 	return false
 	return false

+ 1 - 1
volume/windows_parser.go → volume/mounts/windows_parser.go

@@ -1,4 +1,4 @@
-package volume // import "github.com/docker/docker/volume"
+package mounts // import "github.com/docker/docker/volume/mounts"
 
 
 import (
 import (
 	"errors"
 	"errors"

+ 2 - 1
volume/store/store.go

@@ -14,6 +14,7 @@ import (
 	"github.com/docker/docker/pkg/locker"
 	"github.com/docker/docker/pkg/locker"
 	"github.com/docker/docker/volume"
 	"github.com/docker/docker/volume"
 	"github.com/docker/docker/volume/drivers"
 	"github.com/docker/docker/volume/drivers"
+	volumemounts "github.com/docker/docker/volume/mounts"
 	"github.com/sirupsen/logrus"
 	"github.com/sirupsen/logrus"
 )
 )
 
 
@@ -387,7 +388,7 @@ func (s *VolumeStore) create(name, driverName string, opts, labels map[string]st
 
 
 	// volume name validation is specific to the host os and not on container image
 	// volume name validation is specific to the host os and not on container image
 	// windows/lcow should have an equivalent volumename validation logic so we create a parser for current host OS
 	// windows/lcow should have an equivalent volumename validation logic so we create a parser for current host OS
-	parser := volume.NewParser(runtime.GOOS)
+	parser := volumemounts.NewParser(runtime.GOOS)
 	err := parser.ValidateVolumeName(name)
 	err := parser.ValidateVolumeName(name)
 	if err != nil {
 	if err != nil {
 		return nil, err
 		return nil, err

+ 0 - 162
volume/volume.go

@@ -1,17 +1,7 @@
 package volume // import "github.com/docker/docker/volume"
 package volume // import "github.com/docker/docker/volume"
 
 
 import (
 import (
-	"fmt"
-	"os"
-	"path/filepath"
-	"syscall"
 	"time"
 	"time"
-
-	mounttypes "github.com/docker/docker/api/types/mount"
-	"github.com/docker/docker/pkg/idtools"
-	"github.com/docker/docker/pkg/stringid"
-	"github.com/opencontainers/selinux/go-selinux/label"
-	"github.com/pkg/errors"
 )
 )
 
 
 // DefaultDriverName is the driver name used for the driver
 // DefaultDriverName is the driver name used for the driver
@@ -77,155 +67,3 @@ type DetailedVolume interface {
 	Scope() string
 	Scope() string
 	Volume
 	Volume
 }
 }
-
-// MountPoint is the intersection point between a volume and a container. It
-// specifies which volume is to be used and where inside a container it should
-// be mounted.
-type MountPoint struct {
-	// Source is the source path of the mount.
-	// E.g. `mount --bind /foo /bar`, `/foo` is the `Source`.
-	Source string
-	// Destination is the path relative to the container root (`/`) to the mount point
-	// It is where the `Source` is mounted to
-	Destination string
-	// RW is set to true when the mountpoint should be mounted as read-write
-	RW bool
-	// Name is the name reference to the underlying data defined by `Source`
-	// e.g., the volume name
-	Name string
-	// Driver is the volume driver used to create the volume (if it is a volume)
-	Driver string
-	// Type of mount to use, see `Type<foo>` definitions in github.com/docker/docker/api/types/mount
-	Type mounttypes.Type `json:",omitempty"`
-	// Volume is the volume providing data to this mountpoint.
-	// This is nil unless `Type` is set to `TypeVolume`
-	Volume Volume `json:"-"`
-
-	// Mode is the comma separated list of options supplied by the user when creating
-	// the bind/volume mount.
-	// Note Mode is not used on Windows
-	Mode string `json:"Relabel,omitempty"` // Originally field was `Relabel`"
-
-	// Propagation describes how the mounts are propagated from the host into the
-	// mount point, and vice-versa.
-	// See https://www.kernel.org/doc/Documentation/filesystems/sharedsubtree.txt
-	// Note Propagation is not used on Windows
-	Propagation mounttypes.Propagation `json:",omitempty"` // Mount propagation string
-
-	// Specifies if data should be copied from the container before the first mount
-	// Use a pointer here so we can tell if the user set this value explicitly
-	// This allows us to error out when the user explicitly enabled copy but we can't copy due to the volume being populated
-	CopyData bool `json:"-"`
-	// ID is the opaque ID used to pass to the volume driver.
-	// This should be set by calls to `Mount` and unset by calls to `Unmount`
-	ID string `json:",omitempty"`
-
-	// Sepc is a copy of the API request that created this mount.
-	Spec mounttypes.Mount
-
-	// Track usage of this mountpoint
-	// Specifically needed for containers which are running and calls to `docker cp`
-	// because both these actions require mounting the volumes.
-	active int
-}
-
-// Cleanup frees resources used by the mountpoint
-func (m *MountPoint) Cleanup() error {
-	if m.Volume == nil || m.ID == "" {
-		return nil
-	}
-
-	if err := m.Volume.Unmount(m.ID); err != nil {
-		return errors.Wrapf(err, "error unmounting volume %s", m.Volume.Name())
-	}
-
-	m.active--
-	if m.active == 0 {
-		m.ID = ""
-	}
-	return nil
-}
-
-// Setup sets up a mount point by either mounting the volume if it is
-// configured, or creating the source directory if supplied.
-// The, optional, checkFun parameter allows doing additional checking
-// before creating the source directory on the host.
-func (m *MountPoint) Setup(mountLabel string, rootIDs idtools.IDPair, checkFun func(m *MountPoint) error) (path string, err error) {
-	defer func() {
-		if err != nil || !label.RelabelNeeded(m.Mode) {
-			return
-		}
-
-		var sourcePath string
-		sourcePath, err = filepath.EvalSymlinks(m.Source)
-		if err != nil {
-			path = ""
-			err = errors.Wrapf(err, "error evaluating symlinks from mount source %q", m.Source)
-			return
-		}
-		err = label.Relabel(sourcePath, mountLabel, label.IsShared(m.Mode))
-		if err == syscall.ENOTSUP {
-			err = nil
-		}
-		if err != nil {
-			path = ""
-			err = errors.Wrapf(err, "error setting label on mount source '%s'", sourcePath)
-		}
-	}()
-
-	if m.Volume != nil {
-		id := m.ID
-		if id == "" {
-			id = stringid.GenerateNonCryptoID()
-		}
-		path, err := m.Volume.Mount(id)
-		if err != nil {
-			return "", errors.Wrapf(err, "error while mounting volume '%s'", m.Source)
-		}
-
-		m.ID = id
-		m.active++
-		return path, nil
-	}
-
-	if len(m.Source) == 0 {
-		return "", fmt.Errorf("Unable to setup mount point, neither source nor volume defined")
-	}
-
-	if m.Type == mounttypes.TypeBind {
-		// Before creating the source directory on the host, invoke checkFun if it's not nil. One of
-		// the use case is to forbid creating the daemon socket as a directory if the daemon is in
-		// the process of shutting down.
-		if checkFun != nil {
-			if err := checkFun(m); err != nil {
-				return "", err
-			}
-		}
-		// idtools.MkdirAllNewAs() produces an error if m.Source exists and is a file (not a directory)
-		// also, makes sure that if the directory is created, the correct remapped rootUID/rootGID will own it
-		if err := idtools.MkdirAllAndChownNew(m.Source, 0755, rootIDs); err != nil {
-			if perr, ok := err.(*os.PathError); ok {
-				if perr.Err != syscall.ENOTDIR {
-					return "", errors.Wrapf(err, "error while creating mount source path '%s'", m.Source)
-				}
-			}
-		}
-	}
-	return m.Source, nil
-}
-
-// Path returns the path of a volume in a mount point.
-func (m *MountPoint) Path() string {
-	if m.Volume != nil {
-		return m.Volume.Path()
-	}
-	return m.Source
-}
-
-func errInvalidMode(mode string) error {
-	return errors.Errorf("invalid mode: %v", mode)
-}
-
-func errInvalidSpec(spec string) error {
-	return errors.Errorf("invalid volume specification: '%s'", spec)
-}