| 87 | } |
| 88 | |
| 89 | auto FileDescriptorTable::Free(int fd) -> Expected<void> { |
| 90 | if (fd < 0 || fd >= kMaxFd) { |
| 91 | return std::unexpected(Error(ErrorCode::kFsInvalidFd)); |
| 92 | } |
| 93 | |
| 94 | LockGuard guard(lock_); |
| 95 | |
| 96 | if (table_[fd] == nullptr) { |
| 97 | return std::unexpected(Error(ErrorCode::kFsInvalidFd)); |
| 98 | } |
| 99 | |
| 100 | table_[fd] = nullptr; |
| 101 | --open_count_; |
| 102 | |
| 103 | return {}; |
| 104 | } |
| 105 | |
| 106 | auto FileDescriptorTable::Dup(int old_fd, int new_fd) -> Expected<int> { |
| 107 | if (old_fd < 0 || old_fd >= kMaxFd) { |