commit
19008faf03
|
@ -1,5 +0,0 @@
|
|||
// +build linux freebsd
|
||||
|
||||
package daemon // import "github.com/docker/docker/daemon"
|
||||
|
||||
const bindMountType = "bind"
|
|
@ -141,10 +141,6 @@ func (daemon *Daemon) mountVolumes(container *container.Container) error {
|
|||
if m.Writable {
|
||||
writeMode = "rw"
|
||||
}
|
||||
opts := strings.Join([]string{bindMode, writeMode}, ",")
|
||||
if err := mount.Mount(m.Source, dest, bindMountType, opts); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// mountVolumes() seems to be called for temporary mounts
|
||||
// outside the container. Soon these will be unmounted with
|
||||
|
@ -154,8 +150,9 @@ func (daemon *Daemon) mountVolumes(container *container.Container) error {
|
|||
// then these unmounts will propagate and unmount original
|
||||
// mount as well. So make all these mounts rprivate.
|
||||
// Do not use propagation property of volume as that should
|
||||
// apply only when mounting happen inside the container.
|
||||
if err := mount.MakeRPrivate(dest); err != nil {
|
||||
// apply only when mounting happens inside the container.
|
||||
opts := strings.Join([]string{bindMode, writeMode, "rprivate"}, ",")
|
||||
if err := mount.Mount(m.Source, dest, "", opts); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2092,8 +2092,7 @@ func (s *DockerSuite) TestContainersAPICreateMountsCreate(c *check.C) {
|
|||
assert.NilError(c, err)
|
||||
defer os.RemoveAll(tmpDir3)
|
||||
|
||||
c.Assert(mount.Mount(tmpDir3, tmpDir3, "none", "bind,rw"), checker.IsNil)
|
||||
c.Assert(mount.ForceMount("", tmpDir3, "none", "shared"), checker.IsNil)
|
||||
c.Assert(mount.Mount(tmpDir3, tmpDir3, "none", "bind,shared"), checker.IsNil)
|
||||
|
||||
cases = append(cases, []testCase{
|
||||
{
|
||||
|
|
|
@ -102,13 +102,13 @@ func Mounted(mountpoint string) (bool, error) {
|
|||
// specified like the mount or fstab unix commands: "opt1=val1,opt2=val2". See
|
||||
// flags.go for supported option flags.
|
||||
func Mount(device, target, mType, options string) error {
|
||||
flag, _ := parseOptions(options)
|
||||
flag, data := parseOptions(options)
|
||||
if flag&REMOUNT != REMOUNT {
|
||||
if mounted, err := Mounted(target); err != nil || mounted {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return ForceMount(device, target, mType, options)
|
||||
return mount(device, target, mType, uintptr(flag), data)
|
||||
}
|
||||
|
||||
// ForceMount will mount a filesystem according to the specified configuration,
|
||||
|
|
|
@ -3,49 +3,49 @@ package mount // import "github.com/docker/docker/pkg/mount"
|
|||
// MakeShared ensures a mounted filesystem has the SHARED mount option enabled.
|
||||
// See the supported options in flags.go for further reference.
|
||||
func MakeShared(mountPoint string) error {
|
||||
return ensureMountedAs(mountPoint, "shared")
|
||||
return ensureMountedAs(mountPoint, SHARED)
|
||||
}
|
||||
|
||||
// MakeRShared ensures a mounted filesystem has the RSHARED mount option enabled.
|
||||
// See the supported options in flags.go for further reference.
|
||||
func MakeRShared(mountPoint string) error {
|
||||
return ensureMountedAs(mountPoint, "rshared")
|
||||
return ensureMountedAs(mountPoint, RSHARED)
|
||||
}
|
||||
|
||||
// MakePrivate ensures a mounted filesystem has the PRIVATE mount option enabled.
|
||||
// See the supported options in flags.go for further reference.
|
||||
func MakePrivate(mountPoint string) error {
|
||||
return ensureMountedAs(mountPoint, "private")
|
||||
return ensureMountedAs(mountPoint, PRIVATE)
|
||||
}
|
||||
|
||||
// MakeRPrivate ensures a mounted filesystem has the RPRIVATE mount option
|
||||
// enabled. See the supported options in flags.go for further reference.
|
||||
func MakeRPrivate(mountPoint string) error {
|
||||
return ensureMountedAs(mountPoint, "rprivate")
|
||||
return ensureMountedAs(mountPoint, RPRIVATE)
|
||||
}
|
||||
|
||||
// MakeSlave ensures a mounted filesystem has the SLAVE mount option enabled.
|
||||
// See the supported options in flags.go for further reference.
|
||||
func MakeSlave(mountPoint string) error {
|
||||
return ensureMountedAs(mountPoint, "slave")
|
||||
return ensureMountedAs(mountPoint, SLAVE)
|
||||
}
|
||||
|
||||
// MakeRSlave ensures a mounted filesystem has the RSLAVE mount option enabled.
|
||||
// See the supported options in flags.go for further reference.
|
||||
func MakeRSlave(mountPoint string) error {
|
||||
return ensureMountedAs(mountPoint, "rslave")
|
||||
return ensureMountedAs(mountPoint, RSLAVE)
|
||||
}
|
||||
|
||||
// MakeUnbindable ensures a mounted filesystem has the UNBINDABLE mount option
|
||||
// enabled. See the supported options in flags.go for further reference.
|
||||
func MakeUnbindable(mountPoint string) error {
|
||||
return ensureMountedAs(mountPoint, "unbindable")
|
||||
return ensureMountedAs(mountPoint, UNBINDABLE)
|
||||
}
|
||||
|
||||
// MakeRUnbindable ensures a mounted filesystem has the RUNBINDABLE mount
|
||||
// option enabled. See the supported options in flags.go for further reference.
|
||||
func MakeRUnbindable(mountPoint string) error {
|
||||
return ensureMountedAs(mountPoint, "runbindable")
|
||||
return ensureMountedAs(mountPoint, RUNBINDABLE)
|
||||
}
|
||||
|
||||
// MakeMount ensures that the file or directory given is a mount point,
|
||||
|
@ -59,13 +59,13 @@ func MakeMount(mnt string) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
return Mount(mnt, mnt, "none", "bind")
|
||||
return mount(mnt, mnt, "none", uintptr(BIND), "")
|
||||
}
|
||||
|
||||
func ensureMountedAs(mountPoint, options string) error {
|
||||
if err := MakeMount(mountPoint); err != nil {
|
||||
func ensureMountedAs(mnt string, flags int) error {
|
||||
if err := MakeMount(mnt); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return ForceMount("", mountPoint, "none", options)
|
||||
return mount("", mnt, "none", uintptr(flags), "")
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue