OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "nacl_io/kernel_object.h" | 5 #include "nacl_io/kernel_object.h" |
6 | 6 |
7 #include <assert.h> | 7 #include <assert.h> |
8 #include <errno.h> | 8 #include <errno.h> |
9 #include <fcntl.h> | 9 #include <fcntl.h> |
10 #include <pthread.h> | 10 #include <pthread.h> |
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
155 return 0; | 155 return 0; |
156 } | 156 } |
157 | 157 |
158 mode_t KernelObject::GetUmask() { | 158 mode_t KernelObject::GetUmask() { |
159 return umask_; | 159 return umask_; |
160 } | 160 } |
161 | 161 |
162 mode_t KernelObject::SetUmask(mode_t newmask) { | 162 mode_t KernelObject::SetUmask(mode_t newmask) { |
163 AUTO_LOCK(umask_lock_); | 163 AUTO_LOCK(umask_lock_); |
164 mode_t oldmask = umask_; | 164 mode_t oldmask = umask_; |
165 umask_ = newmask & 0777; | 165 umask_ = newmask & S_MODEBITS; |
166 return oldmask; | 166 return oldmask; |
167 } | 167 } |
168 | 168 |
169 Error KernelObject::GetFDFlags(int fd, int* out_flags) { | 169 Error KernelObject::GetFDFlags(int fd, int* out_flags) { |
170 AUTO_LOCK(handle_lock_); | 170 AUTO_LOCK(handle_lock_); |
171 if (fd < 0 || fd >= static_cast<int>(handle_map_.size())) | 171 if (fd < 0 || fd >= static_cast<int>(handle_map_.size())) |
172 return EBADF; | 172 return EBADF; |
173 | 173 |
174 *out_flags = handle_map_[fd].flags; | 174 *out_flags = handle_map_[fd].flags; |
175 return 0; | 175 return 0; |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
265 AUTO_LOCK(handle_lock_); | 265 AUTO_LOCK(handle_lock_); |
266 | 266 |
267 handle_map_[fd].handle.reset(NULL); | 267 handle_map_[fd].handle.reset(NULL); |
268 free_fds_.push_back(fd); | 268 free_fds_.push_back(fd); |
269 | 269 |
270 // Force lower numbered FD to be available first. | 270 // Force lower numbered FD to be available first. |
271 std::push_heap(free_fds_.begin(), free_fds_.end(), std::greater<int>()); | 271 std::push_heap(free_fds_.begin(), free_fds_.end(), std::greater<int>()); |
272 } | 272 } |
273 | 273 |
274 } // namespace nacl_io | 274 } // namespace nacl_io |
OLD | NEW |