| 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_node.h" | 5 #include "nacl_io/jsfs/js_fs_node.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 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 63 | 63 |
| 64 Error JsFsNode::GetStat(struct stat* stat) { | 64 Error JsFsNode::GetStat(struct stat* stat) { |
| 65 AUTO_LOCK(node_lock_); | 65 AUTO_LOCK(node_lock_); |
| 66 | 66 |
| 67 ScopedVar response(ppapi_); | 67 ScopedVar response(ppapi_); |
| 68 if (!SendRequestAndWait(&response, "%s%d", "cmd", "fstat", "fildes", fd_)) { | 68 if (!SendRequestAndWait(&response, "%s%d", "cmd", "fstat", "fildes", fd_)) { |
| 69 LOG_ERROR("Failed to send request."); | 69 LOG_ERROR("Failed to send request."); |
| 70 return EINVAL; | 70 return EINVAL; |
| 71 } | 71 } |
| 72 | 72 |
| 73 #if defined(__native_client__) | 73 // TODO(binji): find out the size of bionic stat fields. |
| 74 #if defined(__native_client__) && !defined(__BIONIC__) |
| 74 #if defined(__GLIBC__) | 75 #if defined(__GLIBC__) |
| 75 const char* format = "%d%lld%d%d%d%d%lld%lld%lld%lld%lld%lld%lld"; | 76 const char* format = "%d%lld%d%d%d%d%lld%lld%lld%lld%lld%lld%lld"; |
| 76 #else | 77 #else |
| 77 const char* format = "%d%lld%d%d%d%d%lld%lld%d%d%lld%lld%lld"; | 78 const char* format = "%d%lld%d%d%d%d%lld%lld%d%d%lld%lld%lld"; |
| 78 #endif | 79 #endif |
| 79 #else | 80 #else |
| 80 #define FIELD(x) \ | 81 #define FIELD(x) \ |
| 81 if (sizeof(stat->x) == sizeof(int64_t)) \ | 82 if (sizeof(stat->x) == sizeof(int64_t)) \ |
| 82 strcat(format, "%lld"); \ | 83 strcat(format, "%lld"); \ |
| 83 else if (sizeof(stat->x) == sizeof(int16_t)) \ | 84 else if (sizeof(stat->x) == sizeof(int16_t)) \ |
| (...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 364 count = dirents_byte_len - dirents_offs; | 365 count = dirents_byte_len - dirents_offs; |
| 365 | 366 |
| 366 memcpy(pdir, reinterpret_cast<const char*>(dirents) + dirents_offs, count); | 367 memcpy(pdir, reinterpret_cast<const char*>(dirents) + dirents_offs, count); |
| 367 *out_bytes = count; | 368 *out_bytes = count; |
| 368 | 369 |
| 369 free(dirents); | 370 free(dirents); |
| 370 return 0; | 371 return 0; |
| 371 } | 372 } |
| 372 | 373 |
| 373 } // namespace nacl_io | 374 } // namespace nacl_io |
| OLD | NEW |