github.com/pmorton/docker@v1.5.0/pkg/mount/sharedsubtree_linux.go (about)

     1  // +build linux
     2  
     3  package mount
     4  
     5  func MakeShared(mountPoint string) error {
     6  	return ensureMountedAs(mountPoint, "shared")
     7  }
     8  
     9  func MakeRShared(mountPoint string) error {
    10  	return ensureMountedAs(mountPoint, "rshared")
    11  }
    12  
    13  func MakePrivate(mountPoint string) error {
    14  	return ensureMountedAs(mountPoint, "private")
    15  }
    16  
    17  func MakeRPrivate(mountPoint string) error {
    18  	return ensureMountedAs(mountPoint, "rprivate")
    19  }
    20  
    21  func MakeSlave(mountPoint string) error {
    22  	return ensureMountedAs(mountPoint, "slave")
    23  }
    24  
    25  func MakeRSlave(mountPoint string) error {
    26  	return ensureMountedAs(mountPoint, "rslave")
    27  }
    28  
    29  func MakeUnbindable(mountPoint string) error {
    30  	return ensureMountedAs(mountPoint, "unbindable")
    31  }
    32  
    33  func MakeRUnbindable(mountPoint string) error {
    34  	return ensureMountedAs(mountPoint, "runbindable")
    35  }
    36  
    37  func ensureMountedAs(mountPoint, options string) error {
    38  	mounted, err := Mounted(mountPoint)
    39  	if err != nil {
    40  		return err
    41  	}
    42  
    43  	if !mounted {
    44  		if err := Mount(mountPoint, mountPoint, "none", "bind,rw"); err != nil {
    45  			return err
    46  		}
    47  	}
    48  	mounted, err = Mounted(mountPoint)
    49  	if err != nil {
    50  		return err
    51  	}
    52  
    53  	return ForceMount("", mountPoint, "none", options)
    54  }