summaryrefslogtreecommitdiffhomepage
path: root/pkg/sentry/fs/mount.go
diff options
context:
space:
mode:
authorFabricio Voznika <fvoznika@google.com>2019-05-23 04:15:18 -0700
committerShentubot <shentubot@google.com>2019-05-23 04:16:10 -0700
commit9006304dfecf3670ad03c9629f9a4ac3273c386a (patch)
tree958b4c09c1118cd173675618002a2c1f32384071 /pkg/sentry/fs/mount.go
parent022bd0fd1091a29a41fa4c065ac35e45e3d6c576 (diff)
Initial support for bind mounts
Separate MountSource from Mount. This is needed to allow mounts to be shared by multiple containers within the same pod. PiperOrigin-RevId: 249617810 Change-Id: Id2944feb7e4194951f355cbe6d4944ae3c02e468
Diffstat (limited to 'pkg/sentry/fs/mount.go')
-rw-r--r--pkg/sentry/fs/mount.go73
1 files changed, 1 insertions, 72 deletions
diff --git a/pkg/sentry/fs/mount.go b/pkg/sentry/fs/mount.go
index 63fcf4380..41e0d285b 100644
--- a/pkg/sentry/fs/mount.go
+++ b/pkg/sentry/fs/mount.go
@@ -17,7 +17,6 @@ package fs
import (
"bytes"
"fmt"
- "sync"
"sync/atomic"
"gvisor.googlesource.com/gvisor/pkg/refs"
@@ -89,15 +88,7 @@ func (i InodeMappings) String() string {
// one mount source. Each file object may only be represented using one inode
// object in a sentry instance.
//
-// This is an amalgamation of structs super_block, vfsmount, and mount, while
-// MountSourceOperations is akin to struct super_operations.
-//
-// Hence, mount source also contains common mounted file system state, such as
-// mount flags, the root Dirent, and children mounts. For now, this
-// amalgamation implies that a mount source cannot be shared by multiple mounts
-// (e.g. cannot be mounted at different locations).
-//
-// TODO(b/63601033): Move mount-specific information out of MountSource.
+// TODO(b/63601033): Move Flags out of MountSource to Mount.
//
// +stateify savable
type MountSource struct {
@@ -128,22 +119,6 @@ type MountSource struct {
//
// direntRefs must be atomically changed.
direntRefs uint64
-
- // mu protects the fields below, which are set by the MountNamespace
- // during MountSource/Unmount.
- mu sync.Mutex `state:"nosave"`
-
- // id is a unique id for this mount.
- id uint64
-
- // root is the root Dirent of this mount.
- root *Dirent
-
- // parent is the parent MountSource, or nil if this MountSource is the root.
- parent *MountSource
-
- // children are the child MountSources of this MountSource.
- children map[*MountSource]struct{}
}
// DefaultDirentCacheSize is the number of Dirents that the VFS can hold an
@@ -162,53 +137,7 @@ func NewMountSource(mops MountSourceOperations, filesystem Filesystem, flags Mou
Flags: flags,
FilesystemType: fsType,
fscache: NewDirentCache(DefaultDirentCacheSize),
- children: make(map[*MountSource]struct{}),
- }
-}
-
-// Parent returns the parent mount, or nil if this mount is the root.
-func (msrc *MountSource) Parent() *MountSource {
- msrc.mu.Lock()
- defer msrc.mu.Unlock()
- return msrc.parent
-}
-
-// ID returns the ID of this mount.
-func (msrc *MountSource) ID() uint64 {
- msrc.mu.Lock()
- defer msrc.mu.Unlock()
- return msrc.id
-}
-
-// Children returns the (immediate) children of this MountSource.
-func (msrc *MountSource) Children() []*MountSource {
- msrc.mu.Lock()
- defer msrc.mu.Unlock()
-
- ms := make([]*MountSource, 0, len(msrc.children))
- for c := range msrc.children {
- ms = append(ms, c)
}
- return ms
-}
-
-// Submounts returns all mounts that are descendants of this mount.
-func (msrc *MountSource) Submounts() []*MountSource {
- var ms []*MountSource
- for _, c := range msrc.Children() {
- ms = append(ms, c)
- ms = append(ms, c.Submounts()...)
- }
- return ms
-}
-
-// Root returns the root dirent of this mount. Callers must call DecRef on the
-// returned dirent.
-func (msrc *MountSource) Root() *Dirent {
- msrc.mu.Lock()
- defer msrc.mu.Unlock()
- msrc.root.IncRef()
- return msrc.root
}
// DirentRefs returns the current mount direntRefs.