diff options
author | gVisor bot <gvisor-bot@google.com> | 2020-01-28 20:20:25 +0000 |
---|---|---|
committer | gVisor bot <gvisor-bot@google.com> | 2020-01-28 20:20:25 +0000 |
commit | b870658bb6258f1d20fd27a0a711c77b058baf7b (patch) | |
tree | 53c0dd8a46e3b56b9499c696d85a2f0ecf74f162 /pkg/sentry/vfs/vfs.go | |
parent | 03789f35d28783c6c3d659622ccf17b7f8082129 (diff) | |
parent | 1119644080ae57c206b9b0d8d127cf48423af7f2 (diff) |
Merge release-20200115.0-119-g1119644 (automated)
Diffstat (limited to 'pkg/sentry/vfs/vfs.go')
-rwxr-xr-x | pkg/sentry/vfs/vfs.go | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/pkg/sentry/vfs/vfs.go b/pkg/sentry/vfs/vfs.go index b2bf48853..d730530b9 100755 --- a/pkg/sentry/vfs/vfs.go +++ b/pkg/sentry/vfs/vfs.go @@ -75,6 +75,14 @@ type VirtualFilesystem struct { // mountpoints is analogous to Linux's mountpoint_hashtable. mountpoints map[*Dentry]map[*Mount]struct{} + // anonMount is a Mount, not included in mounts or mountpoints, + // representing an anonFilesystem. anonMount is used to back + // VirtualDentries returned by VirtualFilesystem.NewAnonVirtualDentry(). + // anonMount is immutable. + // + // anonMount is analogous to Linux's anon_inode_mnt. + anonMount *Mount + // devices contains all registered Devices. devices is protected by // devicesMu. devicesMu sync.RWMutex @@ -110,6 +118,22 @@ func New() *VirtualFilesystem { filesystems: make(map[*Filesystem]struct{}), } vfs.mounts.Init() + + // Construct vfs.anonMount. + anonfsDevMinor, err := vfs.GetAnonBlockDevMinor() + if err != nil { + panic(fmt.Sprintf("VirtualFilesystem.GetAnonBlockDevMinor() failed during VirtualFilesystem construction: %v", err)) + } + anonfs := anonFilesystem{ + devMinor: anonfsDevMinor, + } + anonfs.vfsfs.Init(vfs, &anonfs) + vfs.anonMount = &Mount{ + vfs: vfs, + fs: &anonfs.vfsfs, + refs: 1, + } + return vfs } |