Chromium Code Reviews| 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 <sys/types.h> // Include something that will define __BIONIC__. | 5 #include <sys/types.h> // Include something that will define __BIONIC__. |
| 6 | 6 |
| 7 // The entire file is wrapped in this #if. We do this so this .cc file can be | 7 // The entire file is wrapped in this #if. We do this so this .cc file can be |
| 8 // compiled, even on a non-bionic build. | 8 // compiled, even on a non-bionic build. |
| 9 | 9 |
| 10 #if defined(__native_client__) && defined(__BIONIC__) | 10 #if defined(__native_client__) && defined(__BIONIC__) |
| (...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 351 int _real_close(int fd) { | 351 int _real_close(int fd) { |
| 352 CHECK_REAL(close); | 352 CHECK_REAL(close); |
| 353 return REAL(close)(fd); | 353 return REAL(close)(fd); |
| 354 } | 354 } |
| 355 | 355 |
| 356 void _real_exit(int status) { | 356 void _real_exit(int status) { |
| 357 REAL(exit)(status); | 357 REAL(exit)(status); |
| 358 } | 358 } |
| 359 | 359 |
| 360 int _real_fchdir(int fd) { | 360 int _real_fchdir(int fd) { |
| 361 CHECK_REAL(fchdir); | 361 CHECK_REAL(fchdir); |
|
binji
2014/09/17 23:30:45
here too?
| |
| 362 return REAL(fchdir)(fd); | 362 return REAL(fchdir)(fd); |
| 363 } | 363 } |
| 364 | 364 |
| 365 int _real_fchmod(int fd, mode_t mode) { | 365 int _real_fchmod(int fd, mode_t mode) { |
| 366 CHECK_REAL(fchmod); | 366 CHECK_REAL(fchmod); |
|
binji
2014/09/17 23:30:45
here too?
| |
| 367 return REAL(fchmod)(fd, mode); | 367 return REAL(fchmod)(fd, mode); |
| 368 } | 368 } |
| 369 | 369 |
| 370 int _real_fdatasync(int fd) { | 370 int _real_fdatasync(int fd) { |
| 371 CHECK_REAL(fdatasync); | 371 CHECK_REAL(fdatasync); |
|
binji
2014/09/17 23:30:45
here too?
| |
| 372 return REAL(fdatasync)(fd); | 372 return REAL(fdatasync)(fd); |
| 373 } | 373 } |
| 374 | 374 |
| 375 int _real_fstat(int fd, struct stat* buf) { | 375 int _real_fstat(int fd, struct stat* buf) { |
| 376 struct nacl_abi_stat st; | 376 struct nacl_abi_stat st; |
| 377 CHECK_REAL(fstat); | 377 CHECK_REAL(fstat); |
| 378 | 378 |
| 379 int err = REAL(fstat)(fd, (struct stat*)&st); | 379 int err = REAL(fstat)(fd, (struct stat*)&st); |
| 380 if (err) { | 380 if (err) { |
| 381 errno = err; | 381 errno = err; |
| 382 return -1; | 382 return -1; |
| 383 } | 383 } |
| 384 | 384 |
| 385 nacl_stat_to_stat(&st, buf); | 385 nacl_stat_to_stat(&st, buf); |
| 386 return 0; | 386 return 0; |
| 387 } | 387 } |
| 388 | 388 |
| 389 int _real_fsync(int fd) { | 389 int _real_fsync(int fd) { |
| 390 CHECK_REAL(fsync); | 390 CHECK_REAL(fsync); |
| 391 return REAL(fsync)(fd); | 391 return REAL(fsync)(fd); |
|
binji
2014/09/17 23:30:45
here too?
| |
| 392 } | 392 } |
| 393 | 393 |
| 394 int _real_getdents(int fd, void* buf, size_t count, size_t* nread) { | 394 int _real_getdents(int fd, void* buf, size_t count, size_t* nread) { |
| 395 // "buf" contains dirent(s); "nacl_buf" contains nacl_abi_dirent(s). | 395 // "buf" contains dirent(s); "nacl_buf" contains nacl_abi_dirent(s). |
| 396 // See WRAP(getdents) above. | 396 // See WRAP(getdents) above. |
| 397 char* nacl_buf = (char*)alloca(count); | 397 char* nacl_buf = (char*)alloca(count); |
| 398 size_t offset = 0; | 398 size_t offset = 0; |
| 399 size_t nacl_offset = 0; | 399 size_t nacl_offset = 0; |
| 400 size_t nacl_nread; | 400 size_t nacl_nread; |
| 401 CHECK_REAL(getdents); | 401 CHECK_REAL(getdents); |
| (...skipping 27 matching lines...) Expand all Loading... | |
| 429 int _real_lseek(int fd, int64_t offset, int whence, int64_t* new_offset) { | 429 int _real_lseek(int fd, int64_t offset, int whence, int64_t* new_offset) { |
| 430 CHECK_REAL(seek); | 430 CHECK_REAL(seek); |
| 431 nacl_abi_off_t nacl_new_offs; | 431 nacl_abi_off_t nacl_new_offs; |
| 432 int ret = REAL(seek)(fd, offset, whence, &nacl_new_offs); | 432 int ret = REAL(seek)(fd, offset, whence, &nacl_new_offs); |
| 433 *new_offset = static_cast<off_t>(nacl_new_offs); | 433 *new_offset = static_cast<off_t>(nacl_new_offs); |
| 434 return ret; | 434 return ret; |
| 435 } | 435 } |
| 436 | 436 |
| 437 int _real_lstat(const char* path, struct stat* buf) { | 437 int _real_lstat(const char* path, struct stat* buf) { |
| 438 struct nacl_abi_stat st; | 438 struct nacl_abi_stat st; |
| 439 CHECK_REAL(fstat); | 439 CHECK_REAL_NOSYS(lstat); |
| 440 | 440 |
| 441 int err = REAL(lstat)(path, (struct stat*)&st); | 441 int err = REAL(lstat)(path, (struct stat*)&st); |
| 442 if (err) { | 442 if (err) { |
| 443 errno = err; | 443 errno = err; |
| 444 return -1; | 444 return -1; |
| 445 } | 445 } |
| 446 | 446 |
| 447 nacl_stat_to_stat(&st, buf); | 447 nacl_stat_to_stat(&st, buf); |
| 448 return 0; | 448 return 0; |
| 449 } | 449 } |
| 450 | 450 |
| 451 int _real_mkdir(const char* pathname, mode_t mode) { | 451 int _real_mkdir(const char* pathname, mode_t mode) { |
| 452 CHECK_REAL(mkdir); | 452 CHECK_REAL_NOSYS(mkdir); |
| 453 return REAL(mkdir)(pathname, mode); | 453 return REAL(mkdir)(pathname, mode); |
| 454 } | 454 } |
| 455 | 455 |
| 456 int _real_mmap(void** addr, | 456 int _real_mmap(void** addr, |
| 457 size_t length, | 457 size_t length, |
| 458 int prot, | 458 int prot, |
| 459 int flags, | 459 int flags, |
| 460 int fd, | 460 int fd, |
| 461 int64_t offset) { | 461 int64_t offset) { |
| 462 CHECK_REAL(mmap); | 462 CHECK_REAL(mmap); |
| 463 return REAL(mmap)(addr, length, prot, flags, fd, offset); | 463 return REAL(mmap)(addr, length, prot, flags, fd, offset); |
| 464 } | 464 } |
| 465 | 465 |
| 466 int _real_munmap(void* addr, size_t length) { | 466 int _real_munmap(void* addr, size_t length) { |
| 467 CHECK_REAL(munmap); | 467 CHECK_REAL(munmap); |
| 468 return REAL(munmap)(addr, length); | 468 return REAL(munmap)(addr, length); |
| 469 } | 469 } |
| 470 | 470 |
| 471 int _real_open(const char* pathname, int oflag, mode_t mode, int* newfd) { | 471 int _real_open(const char* pathname, int oflag, mode_t mode, int* newfd) { |
| 472 CHECK_REAL(open); | 472 CHECK_REAL_NOSYS(open); |
| 473 return REAL(open)(pathname, oflag, mode, newfd); | 473 return REAL(open)(pathname, oflag, mode, newfd); |
| 474 } | 474 } |
| 475 | 475 |
| 476 int _real_open_resource(const char* file, int* fd) { | 476 int _real_open_resource(const char* file, int* fd) { |
| 477 CHECK_REAL(open_resource); | 477 CHECK_REAL_NOSYS(open_resource); |
| 478 return REAL(open_resource)(file, fd); | 478 return REAL(open_resource)(file, fd); |
| 479 } | 479 } |
| 480 | 480 |
| 481 int _real_read(int fd, void* buf, size_t count, size_t* nread) { | 481 int _real_read(int fd, void* buf, size_t count, size_t* nread) { |
| 482 CHECK_REAL(read); | 482 CHECK_REAL(read); |
| 483 return REAL(read)(fd, buf, count, nread); | 483 return REAL(read)(fd, buf, count, nread); |
| 484 } | 484 } |
| 485 | 485 |
| 486 int _real_readlink(const char* path, char* buf, size_t count, size_t* nread) { | 486 int _real_readlink(const char* path, char* buf, size_t count, size_t* nread) { |
| 487 CHECK_REAL(readlink); | 487 CHECK_REAL_NOSYS(readlink); |
| 488 return REAL(readlink)(path, buf, count, nread); | 488 return REAL(readlink)(path, buf, count, nread); |
| 489 } | 489 } |
| 490 | 490 |
| 491 int _real_rmdir(const char* pathname) { | 491 int _real_rmdir(const char* pathname) { |
| 492 CHECK_REAL(rmdir); | 492 CHECK_REAL_NOSYS(rmdir); |
| 493 return REAL(rmdir)(pathname); | 493 return REAL(rmdir)(pathname); |
| 494 } | 494 } |
| 495 | 495 |
| 496 int _real_truncate(const char* pathname, int64_t len) { | 496 int _real_truncate(const char* pathname, int64_t len) { |
| 497 CHECK_REAL(truncate); | 497 CHECK_REAL_NOSYS(truncate); |
| 498 return REAL(truncate)(pathname, len); | 498 return REAL(truncate)(pathname, len); |
| 499 } | 499 } |
| 500 | 500 |
| 501 int _real_write(int fd, const void* buf, size_t count, size_t* nwrote) { | 501 int _real_write(int fd, const void* buf, size_t count, size_t* nwrote) { |
| 502 CHECK_REAL(write); | 502 CHECK_REAL(write); |
| 503 return REAL(write)(fd, buf, count, nwrote); | 503 return REAL(write)(fd, buf, count, nwrote); |
| 504 } | 504 } |
| 505 | 505 |
| 506 int _real_getcwd(char* pathname, size_t len) { | 506 int _real_getcwd(char* pathname, size_t len) { |
| 507 CHECK_REAL_NOSYS(getcwd); | 507 CHECK_REAL_NOSYS(getcwd); |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 521 void kernel_wrap_uninit() { | 521 void kernel_wrap_uninit() { |
| 522 if (s_wrapped) { | 522 if (s_wrapped) { |
| 523 EXPAND_SYMBOL_LIST_OPERATION(USE_REAL) | 523 EXPAND_SYMBOL_LIST_OPERATION(USE_REAL) |
| 524 s_wrapped = false; | 524 s_wrapped = false; |
| 525 } | 525 } |
| 526 } | 526 } |
| 527 | 527 |
| 528 EXTERN_C_END | 528 EXTERN_C_END |
| 529 | 529 |
| 530 #endif // defined(__native_client__) && defined(__BIONIC__) | 530 #endif // defined(__native_client__) && defined(__BIONIC__) |
| OLD | NEW |