| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2008 The Native Client Authors. All rights reserved. | 2 * Copyright (c) 2008 The Native Client Authors. All rights reserved. |
| 3 * Use of this source code is governed by a BSD-style license that can | 3 * Use of this source code is governed by a BSD-style license that can be |
| 4 * be found in the LICENSE file. | 4 * found in the LICENSE file. |
| 5 */ | 5 */ |
| 6 | 6 |
| 7 /* | 7 /* |
| 8 * NaCl Service Runtime. Directory descriptor / Handle abstraction. | 8 * NaCl Service Runtime. Directory descriptor / Handle abstraction. |
| 9 * | 9 * |
| 10 * Note that we avoid using the thread-specific data / thread local | 10 * Note that we avoid using the thread-specific data / thread local |
| 11 * storage access to the "errno" variable, and instead use the raw | 11 * storage access to the "errno" variable, and instead use the raw |
| 12 * system call return interface of small negative numbers as errors. | 12 * system call return interface of small negative numbers as errors. |
| 13 */ | 13 */ |
| 14 | 14 |
| 15 #include <stddef.h> | 15 #include <stddef.h> |
| 16 #include <stdint.h> | 16 #include <stdint.h> |
| 17 #include <string.h> | 17 #include <string.h> |
| 18 #include <sys/types.h> | 18 #include <sys/types.h> |
| 19 #include <sys/stat.h> | 19 #include <sys/stat.h> |
| 20 #include <fcntl.h> | 20 #include <fcntl.h> |
| 21 #include <errno.h> | 21 #include <errno.h> |
| 22 #include <sys/mman.h> | 22 #include <sys/mman.h> |
| 23 #include <unistd.h> | 23 #include <unistd.h> |
| 24 #include <dirent.h> | 24 #include <dirent.h> |
| 25 | 25 |
| 26 #include "native_client/src/include/nacl_platform.h" | 26 #include "native_client/src/include/nacl_platform.h" |
| 27 | 27 |
| 28 #include "native_client/src/shared/platform/nacl_host_desc.h" | 28 #include "native_client/src/shared/platform/nacl_host_desc.h" |
| 29 #include "native_client/src/shared/platform/nacl_host_dir.h" | 29 #include "native_client/src/shared/platform/nacl_host_dir.h" |
| 30 #include "native_client/src/shared/platform/nacl_log.h" | 30 #include "native_client/src/shared/platform/nacl_log.h" |
| 31 #include "native_client/src/shared/platform/nacl_sync.h" | 31 #include "native_client/src/shared/platform/nacl_sync.h" |
| 32 #include "native_client/src/shared/platform/nacl_sync_checked.h" | 32 #include "native_client/src/shared/platform/nacl_sync_checked.h" |
| 33 | 33 |
| 34 #include "native_client/src/trusted/service_runtime/include/bits/mman.h" |
| 34 #include "native_client/src/trusted/service_runtime/include/sys/dirent.h" | 35 #include "native_client/src/trusted/service_runtime/include/sys/dirent.h" |
| 35 #include "native_client/src/trusted/service_runtime/include/sys/errno.h" | 36 #include "native_client/src/trusted/service_runtime/include/sys/errno.h" |
| 36 #include "native_client/src/trusted/service_runtime/include/sys/fcntl.h" | 37 #include "native_client/src/trusted/service_runtime/include/sys/fcntl.h" |
| 37 #include "native_client/src/trusted/service_runtime/include/sys/mman.h" | |
| 38 #include "native_client/src/trusted/service_runtime/include/sys/stat.h" | 38 #include "native_client/src/trusted/service_runtime/include/sys/stat.h" |
| 39 | 39 |
| 40 | 40 |
| 41 #ifndef SSIZE_T_MAX | 41 #ifndef SSIZE_T_MAX |
| 42 # define SSIZE_T_MAX ((ssize_t) ((~(size_t) 0) >> 1)) | 42 # define SSIZE_T_MAX ((ssize_t) ((~(size_t) 0) >> 1)) |
| 43 #endif | 43 #endif |
| 44 | 44 |
| 45 | 45 |
| 46 int NaClHostDirOpen(struct NaClHostDir *d, | 46 int NaClHostDirOpen(struct NaClHostDir *d, |
| 47 char *path) { | 47 char *path) { |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 140 NaClLog(LOG_FATAL, "NaClHostDirClose: 'this' is NULL\n"); | 140 NaClLog(LOG_FATAL, "NaClHostDirClose: 'this' is NULL\n"); |
| 141 } | 141 } |
| 142 NaClLog(3, "NaClHostDirClose(0x%08"NACL_PRIxPTR")\n", (uintptr_t) d->dirp); | 142 NaClLog(3, "NaClHostDirClose(0x%08"NACL_PRIxPTR")\n", (uintptr_t) d->dirp); |
| 143 retval = closedir(d->dirp); | 143 retval = closedir(d->dirp); |
| 144 if (-1 != retval) { | 144 if (-1 != retval) { |
| 145 d->dirp = NULL; | 145 d->dirp = NULL; |
| 146 } | 146 } |
| 147 NaClMutexDtor(&d->mu); | 147 NaClMutexDtor(&d->mu); |
| 148 return (-1 == retval) ? -NaClXlateErrno(errno) : retval; | 148 return (-1 == retval) ? -NaClXlateErrno(errno) : retval; |
| 149 } | 149 } |
| OLD | NEW |