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

Side by Side Diff: libraries/nacl-mounts/base/Entry.cc

Issue 10832154: Fix dup and dup2 in nacl-mounts (Closed) Base URL: http://naclports.googlecode.com/svn/trunk/src/
Patch Set: Created 8 years, 4 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
« no previous file with comments | « no previous file | libraries/nacl-mounts/base/KernelProxy.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2012 The Native Client Authors. All rights reserved. 2 * Copyright (c) 2012 The Native Client Authors. All rights reserved.
3 * Use of this source code is governed by a BSD-style license that can be 3 * Use of this source code is governed by a BSD-style license that can be
4 * found in the LICENSE file. 4 * found in the LICENSE file.
5 */ 5 */
6 #include <errno.h> 6 #include <errno.h>
7 #include <irt.h> 7 #include <irt.h>
8 #ifdef __GLIBC__ 8 #ifdef __GLIBC__
9 #include <irt_syscalls.h> 9 #include <irt_syscalls.h>
10 #endif 10 #endif
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 DECLARE_STRUCT(memory); 42 DECLARE_STRUCT(memory);
43 DECLARE_STRUCT(net); 43 DECLARE_STRUCT(net);
44 #endif 44 #endif
45 45
46 DECLARE(fdio, close); 46 DECLARE(fdio, close);
47 DECLARE(fdio, fstat); 47 DECLARE(fdio, fstat);
48 DECLARE(fdio, getdents); 48 DECLARE(fdio, getdents);
49 DECLARE(fdio, read); 49 DECLARE(fdio, read);
50 DECLARE(fdio, seek); 50 DECLARE(fdio, seek);
51 DECLARE(fdio, write); 51 DECLARE(fdio, write);
52 DECLARE(fdio, dup);
53 DECLARE(fdio, dup2);
52 54
53 DECLARE(filename, open); 55 DECLARE(filename, open);
54 DECLARE(filename, stat); 56 DECLARE(filename, stat);
55 DECLARE(memory, mmap); 57 DECLARE(memory, mmap);
56 58
57 #ifdef __GLIBC__ 59 #ifdef __GLIBC__
58 DECLARE(filepath, chdir); 60 DECLARE(filepath, chdir);
59 DECLARE(filepath, rmdir); 61 DECLARE(filepath, rmdir);
60 DECLARE(filepath, mkdir); 62 DECLARE(filepath, mkdir);
61 DECLARE(filepath, getcwd); 63 DECLARE(filepath, getcwd);
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
210 int WRAP(open)(const char *pathname, int oflag, mode_t cmode, int *newfd) { 212 int WRAP(open)(const char *pathname, int oflag, mode_t cmode, int *newfd) {
211 *newfd = kp->open(pathname, oflag, cmode); 213 *newfd = kp->open(pathname, oflag, cmode);
212 return (*newfd < 0) ? errno : 0; 214 return (*newfd < 0) ? errno : 0;
213 } 215 }
214 216
215 int WRAP(close)(int fd) { 217 int WRAP(close)(int fd) {
216 int res = kp->close(fd); 218 int res = kp->close(fd);
217 return (res < 0) ? errno : 0; 219 return (res < 0) ? errno : 0;
218 } 220 }
219 221
222 int WRAP(dup)(int fd, int *newfd) {
223 int res = kp->dup(fd);
224 if (res < 0)
225 return errno;
226 *newfd = res;
227 return 0;
228 }
229
230 int WRAP(dup2)(int fd, int newfd) {
231 int res = kp->dup2(fd, newfd);
232 return (res < 0) ? errno : 0;
233 }
234
220 int WRAP(read)(int fd, void *buf, size_t count, size_t *nread) { 235 int WRAP(read)(int fd, void *buf, size_t count, size_t *nread) {
221 *nread = kp->read(fd, buf, count); 236 *nread = kp->read(fd, buf, count);
222 return (*nread < 0) ? errno : 0; 237 return (*nread < 0) ? errno : 0;
223 } 238 }
224 239
225 int WRAP(write)(int fd, const void *buf, size_t count, size_t *nwrote) { 240 int WRAP(write)(int fd, const void *buf, size_t count, size_t *nwrote) {
226 *nwrote = kp->write(fd, buf, count); 241 *nwrote = kp->write(fd, buf, count);
227 return (*nwrote < 0) ? errno : 0; 242 return (*nwrote < 0) ? errno : 0;
228 } 243 }
229 244
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after
447 } 462 }
448 463
449 static struct NaClMountsStaticInitializer { 464 static struct NaClMountsStaticInitializer {
450 NaClMountsStaticInitializer() { 465 NaClMountsStaticInitializer() {
451 DO_WRAP(fdio, close); 466 DO_WRAP(fdio, close);
452 DO_WRAP(fdio, fstat); 467 DO_WRAP(fdio, fstat);
453 DO_WRAP(fdio, getdents); 468 DO_WRAP(fdio, getdents);
454 DO_WRAP(fdio, read); 469 DO_WRAP(fdio, read);
455 DO_WRAP(fdio, seek); 470 DO_WRAP(fdio, seek);
456 DO_WRAP(fdio, write); 471 DO_WRAP(fdio, write);
472 DO_WRAP(fdio, dup);
473 DO_WRAP(fdio, dup2);
457 DO_WRAP(filename, open); 474 DO_WRAP(filename, open);
458 DO_WRAP(filename, stat); 475 DO_WRAP(filename, stat);
459 DO_WRAP(memory, mmap); 476 DO_WRAP(memory, mmap);
460 #ifdef __GLIBC__ 477 #ifdef __GLIBC__
461 DO_WRAP(filepath, chdir); 478 DO_WRAP(filepath, chdir);
462 DO_WRAP(filepath, mkdir); 479 DO_WRAP(filepath, mkdir);
463 DO_WRAP(filepath, rmdir); 480 DO_WRAP(filepath, rmdir);
464 DO_WRAP(filepath, getcwd); 481 DO_WRAP(filepath, getcwd);
465 482
466 DO_WRAP(net, select); 483 DO_WRAP(net, select);
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
536 return 0; 553 return 0;
537 } 554 }
538 555
539 void (*signal(int sig, void (*func)(int)))(int) { 556 void (*signal(int sig, void (*func)(int)))(int) {
540 return reinterpret_cast<void(*)(int)>(-1); 557 return reinterpret_cast<void(*)(int)>(-1);
541 } 558 }
542 559
543 }; 560 };
544 561
545 #endif // !__GLIBC__ 562 #endif // !__GLIBC__
OLDNEW
« no previous file with comments | « no previous file | libraries/nacl-mounts/base/KernelProxy.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698