SetFlagsForRange sets the flags for the given range of file descriptors (inclusive: [startFd, endFd]).
(ctx context.Context, startFd int32, endFd int32, flags FDFlags)
| 376 | // SetFlagsForRange sets the flags for the given range of file descriptors |
| 377 | // (inclusive: [startFd, endFd]). |
| 378 | func (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. |