summaryrefslogtreecommitdiffhomepage
path: root/pkg/sentry
diff options
context:
space:
mode:
authorFabricio Voznika <fvoznika@google.com>2019-02-26 09:32:20 -0800
committerShentubot <shentubot@google.com>2019-02-26 09:33:44 -0800
commit23fe059761a470d7724b462ad8ead09356ec21b7 (patch)
tree5f7e697650b3cf44a6b092845a75fdb0e7071cb1 /pkg/sentry
parent33d0e824c73a918ad59586084b47cd53fe07ca36 (diff)
Lazily allocate inotify map on inode
PiperOrigin-RevId: 235735865 Change-Id: I84223eb18eb51da1fa9768feaae80387ff6bfed0
Diffstat (limited to 'pkg/sentry')
-rw-r--r--pkg/sentry/fs/inode_inotify.go7
1 files changed, 4 insertions, 3 deletions
diff --git a/pkg/sentry/fs/inode_inotify.go b/pkg/sentry/fs/inode_inotify.go
index e213df924..d2b653bc7 100644
--- a/pkg/sentry/fs/inode_inotify.go
+++ b/pkg/sentry/fs/inode_inotify.go
@@ -39,9 +39,7 @@ type Watches struct {
}
func newWatches() *Watches {
- return &Watches{
- ws: make(map[uint64]*Watch),
- }
+ return &Watches{}
}
// MarkUnlinked indicates the target for this set of watches to be unlinked.
@@ -78,6 +76,9 @@ func (w *Watches) Add(watch *Watch) {
if _, exists := w.ws[watch.ID()]; exists {
panic(fmt.Sprintf("Watch collision with ID %+v", watch.ID()))
}
+ if w.ws == nil {
+ w.ws = make(map[uint64]*Watch)
+ }
w.ws[watch.ID()] = watch
}