diff options
author | gVisor bot <gvisor-bot@google.com> | 2020-02-12 01:41:02 +0000 |
---|---|---|
committer | gVisor bot <gvisor-bot@google.com> | 2020-02-12 01:41:02 +0000 |
commit | 06dba0b8d49a8f38c5446114ce76afd57eccda93 (patch) | |
tree | b727a71fd3fb48d6d95407acb4ae3d307d3e7a0f /pkg/sentry | |
parent | c0a2d199803924381f73bbe0c562d8cf704b0556 (diff) | |
parent | 6dced977eab69401a114257e386addb9cb03a39d (diff) |
Merge release-20200127.0-133-g6dced97 (automated)
Diffstat (limited to 'pkg/sentry')
-rw-r--r-- | pkg/sentry/fs/fsutil/host_file_mapper.go | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/pkg/sentry/fs/fsutil/host_file_mapper.go b/pkg/sentry/fs/fsutil/host_file_mapper.go index 67278aa86..e82afd112 100644 --- a/pkg/sentry/fs/fsutil/host_file_mapper.go +++ b/pkg/sentry/fs/fsutil/host_file_mapper.go @@ -65,13 +65,18 @@ type mapping struct { writable bool } -// NewHostFileMapper returns a HostFileMapper with no references or cached -// mappings. +// Init must be called on zero-value HostFileMappers before first use. +func (f *HostFileMapper) Init() { + f.refs = make(map[uint64]int32) + f.mappings = make(map[uint64]mapping) +} + +// NewHostFileMapper returns an initialized HostFileMapper allocated on the +// heap with no references or cached mappings. func NewHostFileMapper() *HostFileMapper { - return &HostFileMapper{ - refs: make(map[uint64]int32), - mappings: make(map[uint64]mapping), - } + f := &HostFileMapper{} + f.Init() + return f } // IncRefOn increments the reference count on all offsets in mr. |