| 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_handle.h" | 5 #include "nacl_io/kernel_handle.h" |
| 6 | 6 |
| 7 #include <errno.h> | 7 #include <errno.h> |
| 8 #include <pthread.h> | 8 #include <pthread.h> |
| 9 | 9 |
| 10 #include "nacl_io/filesystem.h" | 10 #include "nacl_io/filesystem.h" |
| (...skipping 22 matching lines...) Expand all Loading... |
| 33 // Returns the SocketNode* if this node is a socket. | 33 // Returns the SocketNode* if this node is a socket. |
| 34 SocketNode* KernelHandle::socket_node() { | 34 SocketNode* KernelHandle::socket_node() { |
| 35 if (node_.get() && node_->IsaSock()) | 35 if (node_.get() && node_->IsaSock()) |
| 36 return reinterpret_cast<SocketNode*>(node_.get()); | 36 return reinterpret_cast<SocketNode*>(node_.get()); |
| 37 return NULL; | 37 return NULL; |
| 38 } | 38 } |
| 39 | 39 |
| 40 Error KernelHandle::Init(int open_flags) { | 40 Error KernelHandle::Init(int open_flags) { |
| 41 handle_attr_.flags = open_flags; | 41 handle_attr_.flags = open_flags; |
| 42 | 42 |
| 43 if (!node_->CanOpen(open_flags)) { | 43 if ((open_flags & O_CREAT) == 0 && !node_->CanOpen(open_flags)) { |
| 44 return EACCES; | 44 return EACCES; |
| 45 } | 45 } |
| 46 | 46 |
| 47 if (open_flags & O_APPEND) { | 47 if (open_flags & O_APPEND) { |
| 48 Error error = node_->GetSize(&handle_attr_.offs); | 48 Error error = node_->GetSize(&handle_attr_.offs); |
| 49 if (error) | 49 if (error) |
| 50 return error; | 50 return error; |
| 51 } | 51 } |
| 52 | 52 |
| 53 return 0; | 53 return 0; |
| (...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 228 return ENOTSOCK; | 228 return ENOTSOCK; |
| 229 if (OpenMode() == O_RDONLY) | 229 if (OpenMode() == O_RDONLY) |
| 230 return EACCES; | 230 return EACCES; |
| 231 | 231 |
| 232 AUTO_LOCK(handle_lock_); | 232 AUTO_LOCK(handle_lock_); |
| 233 return sock->SendTo(handle_attr_, buf, len, flags, dest_addr, addrlen, | 233 return sock->SendTo(handle_attr_, buf, len, flags, dest_addr, addrlen, |
| 234 out_len); | 234 out_len); |
| 235 } | 235 } |
| 236 | 236 |
| 237 } // namespace nacl_io | 237 } // namespace nacl_io |
| OLD | NEW |