diff options
author | Dean Deng <deandeng@google.com> | 2020-04-04 21:01:42 -0700 |
---|---|---|
committer | gVisor bot <gvisor-bot@google.com> | 2020-04-04 21:02:42 -0700 |
commit | 24bee1c1813a691072cff5bad7a528690a99eb5e (patch) | |
tree | fdec3e4bcc1418da069340c4f7d2cd5649f3c4e4 /pkg/sentry/vfs/file_description.go | |
parent | fc99a7ebf0c24b6f7b3cfd6351436373ed54548b (diff) |
Record VFS2 sockets in global socket map.
Updates #1476, #1478, #1484, #1485.
PiperOrigin-RevId: 304845354
Diffstat (limited to 'pkg/sentry/vfs/file_description.go')
-rw-r--r-- | pkg/sentry/vfs/file_description.go | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/pkg/sentry/vfs/file_description.go b/pkg/sentry/vfs/file_description.go index 5df4bbf45..28e93a441 100644 --- a/pkg/sentry/vfs/file_description.go +++ b/pkg/sentry/vfs/file_description.go @@ -182,6 +182,12 @@ func (fd *FileDescription) DecRef() { } } +// Refs returns the current number of references. The returned count +// is inherently racy and is unsafe to use without external synchronization. +func (fd *FileDescription) Refs() int64 { + return atomic.LoadInt64(&fd.refs) +} + // Mount returns the mount on which fd was opened. It does not take a reference // on the returned Mount. func (fd *FileDescription) Mount() *Mount { |