Skip to content

Commit

Permalink
pkg/mount: add more sharesubtree options
Browse files Browse the repository at this point in the history
Signed-off-by: Vincent Batts <vbatts@redhat.com>
  • Loading branch information
vbatts committed Oct 31, 2014
1 parent 107898a commit 06bd66a
Show file tree
Hide file tree
Showing 5 changed files with 65 additions and 1 deletion.
7 changes: 7 additions & 0 deletions pkg/mount/flags.go
Expand Up @@ -37,7 +37,14 @@ func parseOptions(options string) (int, string) {
"nodiratime": {false, NODIRATIME},
"bind": {false, BIND},
"rbind": {false, RBIND},
"unbindable": {false, UNBINDABLE},
"runbindable": {false, RUNBINDABLE},
"private": {false, PRIVATE},
"rprivate": {false, RPRIVATE},
"shared": {false, SHARED},
"rshared": {false, RSHARED},
"slave": {false, SLAVE},
"rslave": {false, RSLAVE},
"relatime": {false, RELATIME},
"norelatime": {true, RELATIME},
"strictatime": {false, STRICTATIME},
Expand Down
7 changes: 7 additions & 0 deletions pkg/mount/flags_freebsd.go
Expand Up @@ -19,7 +19,14 @@ const (
MANDLOCK = 0
NODEV = 0
NODIRATIME = 0
UNBINDABLE = 0
RUNBINDABLE = 0
PRIVATE = 0
RPRIVATE = 0
SHARED = 0
RSHARED = 0
SLAVE = 0
RSLAVE = 0
RBIND = 0
RELATIVE = 0
RELATIME = 0
Expand Down
7 changes: 7 additions & 0 deletions pkg/mount/flags_linux.go
Expand Up @@ -17,7 +17,14 @@ const (
NODIRATIME = syscall.MS_NODIRATIME
BIND = syscall.MS_BIND
RBIND = syscall.MS_BIND | syscall.MS_REC
UNBINDABLE = syscall.MS_UNBINDABLE
RUNBINDABLE = syscall.MS_UNBINDABLE | syscall.MS_REC
PRIVATE = syscall.MS_PRIVATE
RPRIVATE = syscall.MS_PRIVATE | syscall.MS_REC
SLAVE = syscall.MS_SLAVE
RSLAVE = syscall.MS_SLAVE | syscall.MS_REC
SHARED = syscall.MS_SHARED
RSHARED = syscall.MS_SHARED | syscall.MS_REC
RELATIME = syscall.MS_RELATIME
STRICTATIME = syscall.MS_STRICTATIME
)
7 changes: 7 additions & 0 deletions pkg/mount/flags_unsupported.go
Expand Up @@ -11,7 +11,14 @@ const (
NODIRATIME = 0
NOEXEC = 0
NOSUID = 0
UNBINDABLE = 0
RUNBINDABLE = 0
PRIVATE = 0
RPRIVATE = 0
SHARED = 0
RSHARED = 0
SLAVE = 0
RSLAVE = 0
RBIND = 0
RELATIME = 0
RELATIVE = 0
Expand Down
38 changes: 37 additions & 1 deletion pkg/mount/sharedsubtree_linux.go
Expand Up @@ -2,7 +2,39 @@

package mount

func MakeShared(mountPoint string) error {
return ensureMountedAs(mountPoint, "shared")
}

func MakeRShared(mountPoint string) error {
return ensureMountedAs(mountPoint, "rshared")
}

func MakePrivate(mountPoint string) error {
return ensureMountedAs(mountPoint, "private")
}

func MakeRPrivate(mountPoint string) error {
return ensureMountedAs(mountPoint, "rprivate")
}

func MakeSlave(mountPoint string) error {
return ensureMountedAs(mountPoint, "slave")
}

func MakeRSlave(mountPoint string) error {
return ensureMountedAs(mountPoint, "rslave")
}

func MakeUnbindable(mountPoint string) error {
return ensureMountedAs(mountPoint, "unbindable")
}

func MakeRUnbindable(mountPoint string) error {
return ensureMountedAs(mountPoint, "runbindable")
}

func ensureMountedAs(mountPoint, options string) error {
mounted, err := Mounted(mountPoint)
if err != nil {
return err
Expand All @@ -13,6 +45,10 @@ func MakePrivate(mountPoint string) error {
return err
}
}
mounted, err = Mounted(mountPoint)
if err != nil {
return err
}

return ForceMount("", mountPoint, "none", "private")
return ForceMount("", mountPoint, "none", options)
}

0 comments on commit 06bd66a

Please sign in to comment.