github.com/devdivbcp/moby@v17.12.0-ce-rc1.0.20200726071732-2d4bfdc789ad+incompatible/pkg/mount/sharedsubtree_linux.go (about) 1 package mount // import "github.com/docker/docker/pkg/mount" 2 3 // MakeShared ensures a mounted filesystem has the SHARED mount option enabled. 4 // See the supported options in flags.go for further reference. 5 func MakeShared(mountPoint string) error { 6 return ensureMountedAs(mountPoint, SHARED) 7 } 8 9 // MakeRShared ensures a mounted filesystem has the RSHARED mount option enabled. 10 // See the supported options in flags.go for further reference. 11 func MakeRShared(mountPoint string) error { 12 return ensureMountedAs(mountPoint, RSHARED) 13 } 14 15 // MakePrivate ensures a mounted filesystem has the PRIVATE mount option enabled. 16 // See the supported options in flags.go for further reference. 17 func MakePrivate(mountPoint string) error { 18 return ensureMountedAs(mountPoint, PRIVATE) 19 } 20 21 // MakeRPrivate ensures a mounted filesystem has the RPRIVATE mount option 22 // enabled. See the supported options in flags.go for further reference. 23 func MakeRPrivate(mountPoint string) error { 24 return ensureMountedAs(mountPoint, RPRIVATE) 25 } 26 27 // MakeSlave ensures a mounted filesystem has the SLAVE mount option enabled. 28 // See the supported options in flags.go for further reference. 29 func MakeSlave(mountPoint string) error { 30 return ensureMountedAs(mountPoint, SLAVE) 31 } 32 33 // MakeRSlave ensures a mounted filesystem has the RSLAVE mount option enabled. 34 // See the supported options in flags.go for further reference. 35 func MakeRSlave(mountPoint string) error { 36 return ensureMountedAs(mountPoint, RSLAVE) 37 } 38 39 // MakeUnbindable ensures a mounted filesystem has the UNBINDABLE mount option 40 // enabled. See the supported options in flags.go for further reference. 41 func MakeUnbindable(mountPoint string) error { 42 return ensureMountedAs(mountPoint, UNBINDABLE) 43 } 44 45 // MakeRUnbindable ensures a mounted filesystem has the RUNBINDABLE mount 46 // option enabled. See the supported options in flags.go for further reference. 47 func MakeRUnbindable(mountPoint string) error { 48 return ensureMountedAs(mountPoint, RUNBINDABLE) 49 } 50 51 // MakeMount ensures that the file or directory given is a mount point, 52 // bind mounting it to itself it case it is not. 53 func MakeMount(mnt string) error { 54 mounted, err := Mounted(mnt) 55 if err != nil { 56 return err 57 } 58 if mounted { 59 return nil 60 } 61 62 return mount(mnt, mnt, "none", uintptr(BIND), "") 63 } 64 65 func ensureMountedAs(mnt string, flags int) error { 66 if err := MakeMount(mnt); err != nil { 67 return err 68 } 69 70 return mount("", mnt, "none", uintptr(flags), "") 71 }