github.com/rita33cool1/iot-system-gateway@v0.0.0-20200911033302-e65bde238cc5/docker-engine/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  func ensureMountedAs(mountPoint, options string) error {
    52  	mounted, err := Mounted(mountPoint)
    53  	if err != nil {
    54  		return err
    55  	}
    56  
    57  	if !mounted {
    58  		if err := Mount(mountPoint, mountPoint, "none", "bind,rw"); err != nil {
    59  			return err
    60  		}
    61  	}
    62  	if _, err = Mounted(mountPoint); err != nil {
    63  		return err
    64  	}
    65  
    66  	return ForceMount("", mountPoint, "none", options)
    67  }