| OLD | NEW |
| 1 /* Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 /* Copyright (c) 2012 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/mount_node.h" | 5 #include "nacl_io/mount_node.h" |
| 6 | 6 |
| 7 #include <errno.h> | 7 #include <errno.h> |
| 8 #include <fcntl.h> | 8 #include <fcntl.h> |
| 9 #include <string.h> | 9 #include <string.h> |
| 10 #include <sys/stat.h> | 10 #include <sys/stat.h> |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 73 return -1; | 73 return -1; |
| 74 } | 74 } |
| 75 | 75 |
| 76 int MountNode::Write(size_t offs, const void* buf, size_t count) { | 76 int MountNode::Write(size_t offs, const void* buf, size_t count) { |
| 77 errno = EINVAL; | 77 errno = EINVAL; |
| 78 return -1; | 78 return -1; |
| 79 } | 79 } |
| 80 | 80 |
| 81 void* MountNode::MMap(void* addr, size_t length, int prot, int flags, | 81 void* MountNode::MMap(void* addr, size_t length, int prot, int flags, |
| 82 size_t offset) { | 82 size_t offset) { |
| 83 // Never allow mmap'ing PROT_EXEC. The passthrough node supports this, but we |
| 84 // don't. Fortunately, glibc will fallback if this fails, so dlopen will |
| 85 // continue to work. |
| 86 if (prot & PROT_EXEC) { |
| 87 errno = EPERM; |
| 88 return MAP_FAILED; |
| 89 } |
| 90 |
| 83 // This default mmap support is just enough to make dlopen work. | 91 // This default mmap support is just enough to make dlopen work. |
| 84 // This implementation just reads from the mount into the mmap'd memory area. | 92 // This implementation just reads from the mount into the mmap'd memory area. |
| 85 void* new_addr = addr; | 93 void* new_addr = addr; |
| 86 int err = _real_mmap(&new_addr, length, prot | PROT_WRITE, flags | | 94 int err = _real_mmap(&new_addr, length, prot | PROT_WRITE, flags | |
| 87 MAP_ANONYMOUS, -1, 0); | 95 MAP_ANONYMOUS, -1, 0); |
| 88 if (new_addr == MAP_FAILED) { | 96 if (new_addr == MAP_FAILED) { |
| 89 _real_munmap(new_addr, length); | 97 _real_munmap(new_addr, length); |
| 90 errno = err; | 98 errno = err; |
| 91 return MAP_FAILED; | 99 return MAP_FAILED; |
| 92 } | 100 } |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 156 | 164 |
| 157 void MountNode::Link() { | 165 void MountNode::Link() { |
| 158 Acquire(); | 166 Acquire(); |
| 159 stat_.st_nlink++; | 167 stat_.st_nlink++; |
| 160 } | 168 } |
| 161 | 169 |
| 162 void MountNode::Unlink() { | 170 void MountNode::Unlink() { |
| 163 stat_.st_nlink--; | 171 stat_.st_nlink--; |
| 164 Release(); | 172 Release(); |
| 165 } | 173 } |
| OLD | NEW |