summaryrefslogtreecommitdiffhomepage
path: root/pkg/sentry/kernel/fd_table_unsafe.go
diff options
context:
space:
mode:
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