OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #if defined(WIN32) || defined(__linux__) |
| 6 |
| 7 #include <errno.h> |
| 8 |
| 9 #include "nacl_io/kernel_wrap.h" |
| 10 #include "nacl_io/kernel_wrap_real.h" |
| 11 |
| 12 // "real" functions, i.e. the unwrapped original functions. For Windows/Linux |
| 13 // host builds we don't wrap, so the real functions aren't accessible. In most |
| 14 // cases, we just fail. |
| 15 |
| 16 int _real_close(int fd) { |
| 17 return ENOSYS; |
| 18 } |
| 19 |
| 20 int _real_fstat(int fd, struct stat *buf) { |
| 21 return 0; |
| 22 } |
| 23 |
| 24 int _real_getdents(int fd, void* nacl_buf, size_t nacl_count, size_t *nread) { |
| 25 return ENOSYS; |
| 26 } |
| 27 |
| 28 int _real_lseek(int fd, off_t offset, int whence, off_t* new_offset) { |
| 29 return ENOSYS; |
| 30 } |
| 31 |
| 32 int _real_mkdir(const char* pathname, mode_t mode) { |
| 33 return ENOSYS; |
| 34 } |
| 35 |
| 36 int _real_mmap(void** addr, size_t length, int prot, int flags, int fd, |
| 37 off_t offset) { |
| 38 return ENOSYS; |
| 39 } |
| 40 |
| 41 int _real_munmap(void* addr, size_t length) { |
| 42 return ENOSYS; |
| 43 } |
| 44 |
| 45 int _real_open(const char* pathname, int oflag, mode_t cmode, int* newfd) { |
| 46 return ENOSYS; |
| 47 } |
| 48 |
| 49 int _real_open_resource(const char* file, int* fd) { |
| 50 return ENOSYS; |
| 51 } |
| 52 |
| 53 int _real_read(int fd, void *buf, size_t count, size_t *nread) { |
| 54 *nread = count; |
| 55 return 0; |
| 56 } |
| 57 |
| 58 int _real_rmdir(const char* pathname) { |
| 59 return ENOSYS; |
| 60 } |
| 61 |
| 62 int _real_write(int fd, const void *buf, size_t count, size_t *nwrote) { |
| 63 int rtn = write(fd, buf, count); |
| 64 if (rtn < 0) |
| 65 return -1; |
| 66 |
| 67 *nwrote = rtn; |
| 68 return 0; |
| 69 } |
| 70 |
| 71 #endif |
| 72 |
| 73 #if defined(__linux__) |
| 74 |
| 75 void kernel_wrap_init() { |
| 76 } |
| 77 |
| 78 void kernel_wrap_uninit() { |
| 79 } |
| 80 |
| 81 #endif |
OLD | NEW |