Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(328)

Side by Side Diff: native_client_sdk/src/libraries/nacl_io/mount_node.cc

Issue 13488007: [NaCl SDK] Make the SDK examples buildable as a packaged app. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix license headers Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 // This default mmap support is just enough to make dlopen work. 83 // 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. 84 // This implementation just reads from the mount into the mmap'd memory area.
85 void* new_addr = addr; 85 void* new_addr = addr;
86 int err = _real_mmap(&new_addr, length, prot | PROT_WRITE, flags | 86 int err = _real_mmap(&new_addr, length, prot | PROT_WRITE, flags |
87 MAP_ANONYMOUS, -1, 0); 87 MAP_ANONYMOUS, -1, 0);
88 if (addr == MAP_FAILED) { 88 if (new_addr == MAP_FAILED) {
89 _real_munmap(addr, length); 89 _real_munmap(new_addr, length);
90 errno = err; 90 errno = err;
91 return MAP_FAILED; 91 return MAP_FAILED;
92 } 92 }
93 93
94 ssize_t cnt = Read(offset, addr, length); 94 ssize_t cnt = Read(offset, new_addr, length);
95 if (cnt == -1) { 95 if (cnt == -1) {
96 _real_munmap(addr, length); 96 _real_munmap(new_addr, length);
97 errno = ENOSYS; 97 errno = ENOSYS;
98 return MAP_FAILED; 98 return MAP_FAILED;
99 } 99 }
100 100
101 return new_addr; 101 return new_addr;
102 } 102 }
103 103
104 int MountNode::Munmap(void* addr, size_t length) { 104 int MountNode::Munmap(void* addr, size_t length) {
105 return _real_munmap(addr, length); 105 return _real_munmap(addr, length);
106 } 106 }
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
156 156
157 void MountNode::Link() { 157 void MountNode::Link() {
158 Acquire(); 158 Acquire();
159 stat_.st_nlink++; 159 stat_.st_nlink++;
160 } 160 }
161 161
162 void MountNode::Unlink() { 162 void MountNode::Unlink() {
163 stat_.st_nlink--; 163 stat_.st_nlink--;
164 Release(); 164 Release();
165 } 165 }
OLDNEW
« no previous file with comments | « native_client_sdk/src/libraries/nacl_io/mount_http.cc ('k') | native_client_sdk/src/libraries/ppapi_main/ppapi_main.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698