| 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 // TODO(binji): find out the size of bionic stat fields. | 73 #if defined(__native_client__) |
| 74 #if defined(__native_client__) && !defined(__BIONIC__) | |
| 75 #if defined(__GLIBC__) | 74 #if defined(__GLIBC__) |
| 76 const char* format = "%d%lld%d%d%d%d%lld%lld%lld%lld%lld%lld%lld"; | 75 const char* format = "%d%lld%d%d%d%d%lld%lld%lld%lld%lld%lld%lld"; |
| 77 #else | 76 #else |
| 78 const char* format = "%d%lld%d%d%d%d%lld%lld%d%d%lld%lld%lld"; | 77 const char* format = "%d%lld%d%d%d%d%lld%lld%d%d%lld%lld%lld"; |
| 79 #endif | 78 #endif |
| 80 #else | 79 #else |
| 81 #define FIELD(x) \ | 80 #define FIELD(x) \ |
| 82 if (sizeof(stat->x) == sizeof(int64_t)) \ | 81 if (sizeof(stat->x) == sizeof(int64_t)) \ |
| 83 strcat(format, "%lld"); \ | 82 strcat(format, "%lld"); \ |
| 84 else if (sizeof(stat->x) == sizeof(int16_t)) \ | 83 else if (sizeof(stat->x) == sizeof(int16_t)) \ |
| (...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 365 count = dirents_byte_len - dirents_offs; | 364 count = dirents_byte_len - dirents_offs; |
| 366 | 365 |
| 367 memcpy(pdir, reinterpret_cast<const char*>(dirents) + dirents_offs, count); | 366 memcpy(pdir, reinterpret_cast<const char*>(dirents) + dirents_offs, count); |
| 368 *out_bytes = count; | 367 *out_bytes = count; |
| 369 | 368 |
| 370 free(dirents); | 369 free(dirents); |
| 371 return 0; | 370 return 0; |
| 372 } | 371 } |
| 373 | 372 |
| 374 } // namespace nacl_io | 373 } // namespace nacl_io |
| OLD | NEW |