diff options
author | gVisor bot <gvisor-bot@google.com> | 2019-11-26 02:14:18 +0000 |
---|---|---|
committer | gVisor bot <gvisor-bot@google.com> | 2019-11-26 02:14:18 +0000 |
commit | 9eb662f6bf2fb48eb9631002a1c8b5203dc455c7 (patch) | |
tree | 7f47a9ab12148edf3343f70b9c0fc18298c5915f /pkg/sentry/vfs/filesystem.go | |
parent | 11b3c62c47beed4fd8f40177d06f3252fc641a08 (diff) | |
parent | b72e1b3c0873ea29d031db42e39ca053923eecff (diff) |
Merge release-20191114.0-35-gb72e1b3 (automated)
Diffstat (limited to 'pkg/sentry/vfs/filesystem.go')
-rwxr-xr-x | pkg/sentry/vfs/filesystem.go | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/pkg/sentry/vfs/filesystem.go b/pkg/sentry/vfs/filesystem.go index 7a074b718..76ff8cf51 100755 --- a/pkg/sentry/vfs/filesystem.go +++ b/pkg/sentry/vfs/filesystem.go @@ -33,29 +33,41 @@ type Filesystem struct { // operations. refs int64 + // vfs is the VirtualFilesystem that uses this Filesystem. vfs is + // immutable. + vfs *VirtualFilesystem + // impl is the FilesystemImpl associated with this Filesystem. impl is // immutable. This should be the last field in Dentry. impl FilesystemImpl } // Init must be called before first use of fs. -func (fs *Filesystem) Init(impl FilesystemImpl) { +func (fs *Filesystem) Init(vfsObj *VirtualFilesystem, impl FilesystemImpl) { fs.refs = 1 + fs.vfs = vfsObj fs.impl = impl } +// VirtualFilesystem returns the containing VirtualFilesystem. +func (fs *Filesystem) VirtualFilesystem() *VirtualFilesystem { + return fs.vfs +} + // Impl returns the FilesystemImpl associated with fs. func (fs *Filesystem) Impl() FilesystemImpl { return fs.impl } -func (fs *Filesystem) incRef() { +// IncRef increments fs' reference count. +func (fs *Filesystem) IncRef() { if atomic.AddInt64(&fs.refs, 1) <= 1 { - panic("Filesystem.incRef() called without holding a reference") + panic("Filesystem.IncRef() called without holding a reference") } } -func (fs *Filesystem) decRef() { +// DecRef decrements fs' reference count. +func (fs *Filesystem) DecRef() { if refs := atomic.AddInt64(&fs.refs, -1); refs == 0 { fs.impl.Release() } else if refs < 0 { |