-
Notifications
You must be signed in to change notification settings - Fork 115
/
linux_bind_mounter.go
53 lines (41 loc) · 1.8 KB
/
linux_bind_mounter.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
package disk
type linuxBindMounter struct {
delegateMounter Mounter
}
func NewLinuxBindMounter(delegateMounter Mounter) Mounter {
return linuxBindMounter{delegateMounter}
}
func (m linuxBindMounter) Mount(partitionPath, mountPoint string, mountOptions ...string) error {
return m.MountFilesystem(partitionPath, mountPoint, "", mountOptions...)
}
func (m linuxBindMounter) MountFilesystem(partitionPath, mountPoint, fstype string, mountOptions ...string) error {
// Filesystems should not be bind mounted
if fstype != "tmpfs" {
mountOptions = append(mountOptions, "bind")
}
return m.delegateMounter.MountFilesystem(partitionPath, mountPoint, fstype, mountOptions...)
}
func (m linuxBindMounter) RemountAsReadonly(mountPoint string) error {
// Remounting mount points mounted originally by warden with '-o ro --bind' flags does not work.
// See https://lwn.net/Articles/281157/.
return nil
}
func (m linuxBindMounter) Remount(fromMountPoint, toMountPoint string, mountOptions ...string) error {
mountOptions = append(mountOptions, "bind")
return m.delegateMounter.Remount(fromMountPoint, toMountPoint, mountOptions...)
}
func (m linuxBindMounter) SwapOn(partitionPath string) (err error) {
return m.delegateMounter.SwapOn(partitionPath)
}
func (m linuxBindMounter) Unmount(partitionOrMountPoint string) (bool, error) {
return m.delegateMounter.Unmount(partitionOrMountPoint)
}
func (m linuxBindMounter) IsMountPoint(path string) (string, bool, error) {
return m.delegateMounter.IsMountPoint(path)
}
func (m linuxBindMounter) IsMounted(partitionOrMountPoint string) (bool, error) {
return m.delegateMounter.IsMounted(partitionOrMountPoint)
}
func (m linuxBindMounter) RemountInPlace(mountPoint string, mountOptions ...string) (err error) {
return m.delegateMounter.RemountInPlace(mountPoint, mountOptions...)
}