| OLD | NEW |
| 1 /* Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 /* Copyright (c) 2013 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 #if defined(WIN32) | 5 #if defined(WIN32) |
| 6 #define _CRT_RAND_S | 6 #define _CRT_RAND_S |
| 7 #endif | 7 #endif |
| 8 | 8 |
| 9 #include <errno.h> | 9 #include <errno.h> |
| 10 #include <fcntl.h> | 10 #include <fcntl.h> |
| (...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 227 uint32_t len = static_cast<uint32_t>(message.size()); | 227 uint32_t len = static_cast<uint32_t>(message.size()); |
| 228 struct PP_Var val = var_intr->VarFromUtf8(message.data(), len); | 228 struct PP_Var val = var_intr->VarFromUtf8(message.data(), len); |
| 229 msg_intr->PostMessage(mount_->ppapi()->GetInstance(), val); | 229 msg_intr->PostMessage(mount_->ppapi()->GetInstance(), val); |
| 230 *out_bytes = count; | 230 *out_bytes = count; |
| 231 return 0; | 231 return 0; |
| 232 } | 232 } |
| 233 | 233 |
| 234 Error TtyNode::Read(size_t offs, void* buf, size_t count, int* out_bytes) { | 234 Error TtyNode::Read(size_t offs, void* buf, size_t count, int* out_bytes) { |
| 235 AutoLock lock(&lock_); | 235 AutoLock lock(&lock_); |
| 236 while (input_buffer_.size() <= 0) { | 236 while (input_buffer_.size() <= 0) { |
| 237 pthread_cond_wait(&is_readable_, &lock_); | 237 pthread_cond_wait(&is_readable_, lock_); |
| 238 } | 238 } |
| 239 | 239 |
| 240 // Copies data from the input buffer into buf. | 240 // Copies data from the input buffer into buf. |
| 241 size_t bytes_to_copy = std::min(count, input_buffer_.size()); | 241 size_t bytes_to_copy = std::min(count, input_buffer_.size()); |
| 242 std::copy(input_buffer_.begin(), input_buffer_.begin() + bytes_to_copy, | 242 std::copy(input_buffer_.begin(), input_buffer_.begin() + bytes_to_copy, |
| 243 static_cast<char*>(buf)); | 243 static_cast<char*>(buf)); |
| 244 *out_bytes = bytes_to_copy; | 244 *out_bytes = bytes_to_copy; |
| 245 input_buffer_.erase(input_buffer_.begin(), | 245 input_buffer_.erase(input_buffer_.begin(), |
| 246 input_buffer_.begin() + bytes_to_copy); | 246 input_buffer_.begin() + bytes_to_copy); |
| 247 return 0; | 247 return 0; |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 356 | 356 |
| 357 // Don't allow execute access. | 357 // Don't allow execute access. |
| 358 if (a_mode & X_OK) | 358 if (a_mode & X_OK) |
| 359 return EACCES; | 359 return EACCES; |
| 360 | 360 |
| 361 return 0; | 361 return 0; |
| 362 } | 362 } |
| 363 | 363 |
| 364 Error MountDev::Open(const Path& path, int mode, ScopedMountNode* out_node) { | 364 Error MountDev::Open(const Path& path, int mode, ScopedMountNode* out_node) { |
| 365 out_node->reset(NULL); | 365 out_node->reset(NULL); |
| 366 AutoLock lock(&lock_); | |
| 367 | 366 |
| 368 // Don't allow creating any files. | 367 // Don't allow creating any files. |
| 369 if (mode & O_CREAT) | 368 if (mode & O_CREAT) |
| 370 return EINVAL; | 369 return EINVAL; |
| 371 | 370 |
| 372 return root_->FindChild(path.Join(), out_node); | 371 return root_->FindChild(path.Join(), out_node); |
| 373 } | 372 } |
| 374 | 373 |
| 375 Error MountDev::Unlink(const Path& path) { return EINVAL; } | 374 Error MountDev::Unlink(const Path& path) { return EINVAL; } |
| 376 | 375 |
| (...skipping 30 matching lines...) Expand all Loading... |
| 407 INITIALIZE_DEV_NODE_1("/console2", ConsoleNode, PP_LOGLEVEL_WARNING); | 406 INITIALIZE_DEV_NODE_1("/console2", ConsoleNode, PP_LOGLEVEL_WARNING); |
| 408 INITIALIZE_DEV_NODE_1("/console3", ConsoleNode, PP_LOGLEVEL_ERROR); | 407 INITIALIZE_DEV_NODE_1("/console3", ConsoleNode, PP_LOGLEVEL_ERROR); |
| 409 INITIALIZE_DEV_NODE("/tty", TtyNode); | 408 INITIALIZE_DEV_NODE("/tty", TtyNode); |
| 410 INITIALIZE_DEV_NODE_1("/stdin", RealNode, 0); | 409 INITIALIZE_DEV_NODE_1("/stdin", RealNode, 0); |
| 411 INITIALIZE_DEV_NODE_1("/stdout", RealNode, 1); | 410 INITIALIZE_DEV_NODE_1("/stdout", RealNode, 1); |
| 412 INITIALIZE_DEV_NODE_1("/stderr", RealNode, 2); | 411 INITIALIZE_DEV_NODE_1("/stderr", RealNode, 2); |
| 413 | 412 |
| 414 return 0; | 413 return 0; |
| 415 } | 414 } |
| 416 | 415 |
| OLD | NEW |