OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/jsfs/js_fs.h" | 5 #include "nacl_io/jsfs/js_fs.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 <limits.h> | 10 #include <limits.h> |
(...skipping 373 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
384 if (iter != responses_.end()) { | 384 if (iter != responses_.end()) { |
385 PP_Var response = iter->second; | 385 PP_Var response = iter->second; |
386 responses_.erase(iter); | 386 responses_.erase(iter); |
387 return response; | 387 return response; |
388 } | 388 } |
389 | 389 |
390 pthread_cond_wait(&response_cond_, lock_.mutex()); | 390 pthread_cond_wait(&response_cond_, lock_.mutex()); |
391 } | 391 } |
392 } | 392 } |
393 | 393 |
394 Error JsFs::Access(const Path& path, int a_mode) { | |
395 ScopedVar response(ppapi_); | |
396 if (!SendRequestAndWait(&response, "%s%s%d", | |
397 "cmd", "access", | |
398 "path", path.Join().c_str(), | |
399 "amode", a_mode)) { | |
400 LOG_ERROR("Failed to send request."); | |
401 return EINVAL; | |
402 } | |
403 | |
404 return ErrorFromResponse(response); | |
405 } | |
406 | |
407 Error JsFs::Open(const Path& path, int open_flags, ScopedNode* out_node) { | 394 Error JsFs::Open(const Path& path, int open_flags, ScopedNode* out_node) { |
408 out_node->reset(NULL); | 395 out_node->reset(NULL); |
409 ScopedVar response(ppapi_); | 396 ScopedVar response(ppapi_); |
410 if (!SendRequestAndWait(&response, "%s%s%d", | 397 if (!SendRequestAndWait(&response, "%s%s%d", |
411 "cmd", "open", | 398 "cmd", "open", |
412 "path", path.Join().c_str(), | 399 "path", path.Join().c_str(), |
413 "oflag", open_flags)) { | 400 "oflag", open_flags)) { |
414 LOG_ERROR("Failed to send request."); | 401 LOG_ERROR("Failed to send request."); |
415 return EINVAL; | 402 return EINVAL; |
416 } | 403 } |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
504 LOG_TRACE("ioctl with no \"id\", ignoring.\n"); | 491 LOG_TRACE("ioctl with no \"id\", ignoring.\n"); |
505 return EINVAL; | 492 return EINVAL; |
506 } | 493 } |
507 | 494 |
508 responses_.insert(ResponseMap_t::value_type(response_id, response)); | 495 responses_.insert(ResponseMap_t::value_type(response_id, response)); |
509 pthread_cond_broadcast(&response_cond_); | 496 pthread_cond_broadcast(&response_cond_); |
510 return 0; | 497 return 0; |
511 } | 498 } |
512 | 499 |
513 } // namespace nacl_io | 500 } // namespace nacl_io |
OLD | NEW |