MCPcopy
hub / github.com/google/gvisor / SetFlagsForRange

Method SetFlagsForRange

pkg/sentry/kernel/fd_table.go:378–395  ·  view source on GitHub ↗

SetFlagsForRange sets the flags for the given range of file descriptors (inclusive: [startFd, endFd]).

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

Source from the content-addressed store, hash-verified

376// SetFlagsForRange sets the flags for the given range of file descriptors
377// (inclusive: [startFd, endFd]).
378func (f *FDTable) SetFlagsForRange(ctx context.Context, startFd int32, endFd int32, flags FDFlags) error {
379 if startFd < 0 || startFd > endFd {
380 return unix.EBADF
381 }
382
383 f.mu.Lock()
384 defer f.mu.Unlock()
385
386 for fd, err := f.fdBitmap.FirstOne(uint32(startFd)); err == nil && fd <= uint32(endFd); fd, err = f.fdBitmap.FirstOne(fd + 1) {
387 fdI32 := int32(fd)
388 file, _, _ := f.get(fdI32)
389 if df := f.set(fdI32, file, flags); df != nil {
390 panic("file changed")
391 }
392 }
393
394 return nil
395}
396
397// Get returns a reference to the file and the flags for the FD or nil if no
398// file is defined for the given fd.

Callers 2

CloseRangeFunction · 0.80
TestSetFlagsForRangeFunction · 0.80

Calls 5

getMethod · 0.95
setMethod · 0.95
FirstOneMethod · 0.80
LockMethod · 0.65
UnlockMethod · 0.65

Tested by 1

TestSetFlagsForRangeFunction · 0.64