summaryrefslogtreecommitdiffhomepage
path: root/pkg/sentry/kernel/fd_table_unsafe.go
diff options
context:
space:
mode:
authorgVisor bot <gvisor-bot@google.com>2020-09-14 18:41:03 +0000
committergVisor bot <gvisor-bot@google.com>2020-09-14 18:41:03 +0000
commite3f79dba6beb6b83b5db7e8bba9b59cdb4aa0890 (patch)
tree848c369e46e5a93be57a3f2e50a21b4ca68d1191 /pkg/sentry/kernel/fd_table_unsafe.go
parent2bec0281c6dcf60e2c34c1046d2f9465446df095 (diff)
parent2969b17405d248acbb8a0839fc57ff0a44ec1977 (diff)
Merge release-20200907.0-40-g2969b1740 (automated)
Diffstat (limited to 'pkg/sentry/kernel/fd_table_unsafe.go')
-rw-r--r--pkg/sentry/kernel/fd_table_unsafe.go7
1 files changed, 7 insertions, 0 deletions
diff --git a/pkg/sentry/kernel/fd_table_unsafe.go b/pkg/sentry/kernel/fd_table_unsafe.go
index 555b14f8e..1c977b60f 100644
--- a/pkg/sentry/kernel/fd_table_unsafe.go
+++ b/pkg/sentry/kernel/fd_table_unsafe.go
@@ -79,6 +79,13 @@ func (f *FDTable) getAll(fd int32) (*fs.File, *vfs.FileDescription, FDFlags, boo
return d.file, d.fileVFS2, d.flags, true
}
+// CurrentMaxFDs returns the number of file descriptors that may be stored in f
+// without reallocation.
+func (f *FDTable) CurrentMaxFDs() int {
+ slice := *(*[]unsafe.Pointer)(atomic.LoadPointer(&f.slice))
+ return len(slice)
+}
+
// set sets an entry.
//
// This handles accounting changes, as well as acquiring and releasing the