MCPcopy Index your code
hub / github.com/google/gvisor / RemoveNextInRange

Method RemoveNextInRange

pkg/sentry/kernel/fd_table.go:514–537  ·  view source on GitHub ↗

RemoveNextInRange removes the next FD that falls within the given range, and returns the FD number and FileDescription of the removed FD. N.B. Callers are required to use DecRef on the returned file when they are done.

(ctx context.Context, startFd int32, endFd int32)

Source from the content-addressed store, hash-verified

512//
513// N.B. Callers are required to use DecRef on the returned file when they are done.
514func (f *FDTable) RemoveNextInRange(ctx context.Context, startFd int32, endFd int32) (int32, *vfs.FileDescription) {
515 if startFd < 0 || startFd > endFd {
516 return MaxFdLimit, nil
517 }
518
519 f.mu.Lock()
520 fdUint, err := f.fdBitmap.FirstOne(uint32(startFd))
521 fd := int32(fdUint)
522 if err != nil || fd > endFd {
523 f.mu.Unlock()
524 return MaxFdLimit, nil
525 }
526 df := f.set(fd, nil, FDFlags{}) // Zap entry.
527 if df != nil {
528 f.fdBitmap.Remove(uint32(fd))
529 }
530 f.mu.Unlock()
531
532 if df != nil {
533 f.fileUnlock(ctx, df)
534 // Table's reference on df is transferred to caller, so don't DecRef.
535 }
536 return fd, df
537}
538
539// GetLastFd returns the last set FD in the FDTable bitmap.
540func (f *FDTable) GetLastFd() int32 {

Callers 1

CloseRangeFunction · 0.80

Calls 6

setMethod · 0.95
fileUnlockMethod · 0.95
FirstOneMethod · 0.80
LockMethod · 0.65
UnlockMethod · 0.65
RemoveMethod · 0.45

Tested by

no test coverage detected