Changeset 117751 for trunk/base
- Timestamp:
- Mar 10, 2014, 9:55:33 PM (10 years ago)
- Location:
- trunk/base/src
- Files:
-
- 14 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/base/src/darwintracelib1.0/access.c
r114131 r117751 42 42 #include <unistd.h> 43 43 44 int access(const char *path, int amode) {44 int _dt_access(const char *path, int amode) { 45 45 #define access(x, y) syscall(SYS_access, (x), (y)) 46 46 __darwintrace_setup(); … … 60 60 #undef access 61 61 } 62 63 DARWINTRACE_INTERPOSE(_dt_access, access); -
trunk/base/src/darwintracelib1.0/close.c
r113026 r117751 51 51 * will be set to the FD to be closed when closing should be allowed. 52 52 */ 53 int close(int fd) {53 int _dt_close(int fd) { 54 54 #define close(x) syscall(SYS_close, (x)) 55 55 __darwintrace_setup(); … … 67 67 #undef close 68 68 } 69 70 DARWINTRACE_INTERPOSE(_dt_close, close); -
trunk/base/src/darwintracelib1.0/darwintrace.h
r114131 r117751 43 43 #include <stdbool.h> 44 44 #include <stdio.h> 45 46 /** 47 * DARWINTRACE_INTERPOSE: provides a way to override standard library functions 48 * with your own implementations. 49 */ 50 #ifndef DARWINTRACE_INTERPOSE 51 #define DARWINTRACE_INTERPOSE(_replacement, _replacee) \ 52 __attribute__((used)) static struct { \ 53 const void *replacement; \ 54 const void *replacee; \ 55 } _interpose_##_replacee \ 56 __attribute__((section ("__DATA,__interpose"))) = { \ 57 (const void *) (unsigned long) &_replacement, \ 58 (const void *) (unsigned long) &_replacee \ 59 } 60 #endif 45 61 46 62 /** -
trunk/base/src/darwintracelib1.0/dup2.c
r113026 r117751 49 49 * FDs are numbered in ascending order. 50 50 */ 51 int dup2(int filedes, int filedes2) {51 int _dt_dup2(int filedes, int filedes2) { 52 52 #define dup2(x, y) syscall(SYS_dup2, (x), (y)) 53 53 __darwintrace_setup(); … … 76 76 #undef dup2 77 77 } 78 79 DARWINTRACE_INTERPOSE(_dt_dup2, dup2); -
trunk/base/src/darwintracelib1.0/mkdir.c
r114166 r117751 54 54 * outside the sandbox that already exist. 55 55 */ 56 int mkdir(const char *path, mode_t mode) {56 int _dt_mkdir(const char *path, mode_t mode) { 57 57 #define mkdir(x,y) syscall(SYS_mkdir, (x), (y)) 58 58 #define lstat(x,y) syscall(LSTATSYSNUM, (x), (y)) … … 79 79 #undef mkdir 80 80 } 81 82 DARWINTRACE_INTERPOSE(_dt_mkdir, mkdir); -
trunk/base/src/darwintracelib1.0/open.c
r114131 r117751 49 49 * when attempting to create a file, i.e., when \c O_CREAT is set. 50 50 */ 51 int open(const char *path, int flags, ...) {51 int _dt_open(const char *path, int flags, ...) { 52 52 #define open(x,y,z) syscall(SYS_open, (x), (y), (z)) 53 53 __darwintrace_setup(); … … 71 71 #undef open 72 72 } 73 74 DARWINTRACE_INTERPOSE(_dt_open, open); -
trunk/base/src/darwintracelib1.0/proc.c
r114131 r117751 255 255 * using \c check_interpreter. 256 256 */ 257 int execve(const char *path, char *const argv[], char *const envp[]) {257 int _dt_execve(const char *path, char *const argv[], char *const envp[]) { 258 258 #define execve(x,y,z) syscall(SYS_execve, (x), (y), (z)) 259 259 __darwintrace_setup(); … … 290 290 } 291 291 292 DARWINTRACE_INTERPOSE(_dt_execve, execve); 293 292 294 #if defined(HAVE_SPAWN_H) && defined(HAVE_POSIX_SPAWN) 293 295 // Let's save some typing work... … … 304 306 * using \c check_interpreter. 305 307 */ 306 int posix_spawn(pid_t *restrict pid, const char *restrict path, const posix_spawn_file_actions_t *file_actions,308 int _dt_posix_spawn(pid_t *restrict pid, const char *restrict path, const posix_spawn_file_actions_t *file_actions, 307 309 const posix_spawnattr_t *restrict attrp, char *const argv[restrict], char *const envp[restrict]) { 308 310 __darwintrace_setup(); 309 311 310 static posix_spawn_t prev_posix_spawn = NULL;311 312 int result = 0; 312 313 … … 340 341 * either, because that will fail with an invalid argument. Thus, 341 342 * we need to call the original posix_spawn from here. */ 342 // retrieve the original posix_spawn function343 if (prev_posix_spawn == NULL) {344 prev_posix_spawn = (posix_spawn_t) dlsym(RTLD_NEXT, "posix_spawn");345 }346 343 // call the original posix_spawn function, but restore environment 347 344 char **newenv = restore_env(envp); 348 result = p rev_posix_spawn(pid, path, file_actions, attrp, argv, newenv);345 result = posix_spawn(pid, path, file_actions, attrp, argv, newenv); 349 346 free(newenv); 350 347 } … … 355 352 return result; 356 353 } 354 355 DARWINTRACE_INTERPOSE(_dt_posix_spawn, posix_spawn); 357 356 #endif -
trunk/base/src/darwintracelib1.0/readdir.c
r113026 r117751 67 67 }; 68 68 69 size_t _ _getdirentries64(int fd, void *buf, size_t bufsize, __darwin_off_t *basep) {69 size_t _dt_getdirentries64(int fd, void *buf, size_t bufsize, __darwin_off_t *basep) { 70 70 #define __getdirentries64(w,x,y,z) syscall(SYS_getdirentries64, (w), (x), (y), (z)) 71 71 __darwintrace_setup(); … … 106 106 } 107 107 108 // __getdirentries64(2) is private API. There's no header for it. 109 size_t __getdirentries64(int fd, void *buf, size_t bufsize, __darwin_off_t *basep); 110 DARWINTRACE_INTERPOSE(_dt_getdirentries64, __getdirentries64); 111 108 112 #endif /* defined(__DARWIN_64_BIT_INO_T) */ 109 113 … … 118 122 #pragma pack() 119 123 120 int getdirentries(int fd, char *buf, int nbytes, long *basep) {124 int _dt_getdirentries(int fd, char *buf, int nbytes, long *basep) { 121 125 #define getdirentries(w,x,y,z) syscall(SYS_getdirentries, (w), (x), (y), (z)) 122 126 __darwintrace_setup(); … … 155 159 #undef getdirentries 156 160 } 161 162 int getdirentries(int fd, char *buf, int nbytes, long *basep); 163 DARWINTRACE_INTERPOSE(_dt_getdirentries, getdirentries); -
trunk/base/src/darwintracelib1.0/readlink.c
r114131 r117751 47 47 */ 48 48 #ifdef READLINK_IS_NOT_P1003_1A 49 int readlink(const char *path, char *buf, int bufsiz) {49 int _dt_readlink(const char *path, char *buf, int bufsiz) { 50 50 #else 51 ssize_t readlink(const char *path, char *buf, size_t bufsiz) {51 ssize_t _dt_readlink(const char *path, char *buf, size_t bufsiz) { 52 52 #endif 53 53 #define readlink(x,y,z) syscall(SYS_readlink, (x), (y), (z)) … … 70 70 #undef readlink 71 71 } 72 73 DARWINTRACE_INTERPOSE(_dt_readlink, readlink); -
trunk/base/src/darwintracelib1.0/rename.c
r114131 r117751 47 47 * sandbox. 48 48 */ 49 int rename(const char *from, const char *to) {49 int _dt_rename(const char *from, const char *to) { 50 50 #define rename(x,y) syscall(SYS_rename, (x), (y)) 51 51 __darwintrace_setup(); … … 68 68 #undef rename 69 69 } 70 71 DARWINTRACE_INTERPOSE(_dt_rename, rename); -
trunk/base/src/darwintracelib1.0/rmdir.c
r114131 r117751 47 47 * sandbox. 48 48 */ 49 int rmdir(const char *path) {49 int _dt_rmdir(const char *path) { 50 50 #define rmdir(x) syscall(SYS_rmdir, (x)) 51 51 __darwintrace_setup(); … … 65 65 #undef rmdir 66 66 } 67 68 DARWINTRACE_INTERPOSE(_dt_rmdir, rmdir); -
trunk/base/src/darwintracelib1.0/stat.c
r114131 r117751 48 48 * sandbox. 49 49 */ 50 int stat(const char *path, void *sb) {50 int _dt_stat(const char *path, void *sb) { 51 51 #define stat(path, sb) syscall(SYS_stat, path, sb) 52 52 __darwintrace_setup(); … … 67 67 } 68 68 69 // We don't include sys/stat.h because it would rewrite all stat function 70 // calls, but we need the declaration of stat here. 71 int stat(const char *path, void *sb); 72 DARWINTRACE_INTERPOSE(_dt_stat, stat); 73 69 74 // Don't provide stat64 on systems that have no stat64 syscall 70 75 #ifdef SYS_stat64 71 int stat64(const char *path, void *sb) {76 int _dt_stat64(const char *path, void *sb) { 72 77 #define stat64(path, sb) syscall(SYS_stat64, path, sb) 73 78 __darwintrace_setup(); … … 87 92 #undef stat64 88 93 } 94 int stat64(const char *path, void *sb); 95 DARWINTRACE_INTERPOSE(_dt_stat64, stat64); 89 96 90 int stat$INODE64(const char *path, void *sb) {91 return stat64(path, sb);92 } 97 int stat$INODE64(const char *path, void *sb); 98 DARWINTRACE_INTERPOSE(_dt_stat64, stat$INODE64); 99 93 100 #endif /* defined(SYS_stat64) */ 94 101 95 int lstat(const char *path, void *sb) {102 int _dt_lstat(const char *path, void *sb) { 96 103 #define lstat(path, sb) syscall(SYS_lstat, path, sb) 97 104 __darwintrace_setup(); … … 113 120 } 114 121 122 int lstat(const char *path, void *sb); 123 DARWINTRACE_INTERPOSE(_dt_lstat, lstat); 124 115 125 // Don't provide lstat64 on systems that have no lstat64 syscall 116 126 #ifdef SYS_lstat64 117 int lstat64(const char *path, void *sb) {127 int _dt_lstat64(const char *path, void *sb) { 118 128 #define lstat64(path, sb) syscall(SYS_lstat64, path, sb) 119 129 __darwintrace_setup(); … … 135 145 } 136 146 137 int lstat$INODE64(const char *path, void *sb) { 138 return lstat64(path, sb); 139 } 147 int lstat64(const char *path, void *sb); 148 DARWINTRACE_INTERPOSE(_dt_lstat64, lstat64); 149 150 int lstat$INODE64(const char *path, void *sb); 151 DARWINTRACE_INTERPOSE(_dt_lstat64, lstat$INODE64); 152 140 153 #endif /* defined(SYS_lstat64) */ -
trunk/base/src/darwintracelib1.0/unlink.c
r114131 r117751 47 47 * of the sandbox and simulate non-existence of the file instead. 48 48 */ 49 int unlink(const char *path) {49 int _dt_unlink(const char *path) { 50 50 #define unlink(x) syscall(SYS_unlink, (x)) 51 51 __darwintrace_setup(); … … 65 65 #undef unlink 66 66 } 67 68 DARWINTRACE_INTERPOSE(_dt_unlink, unlink); -
trunk/base/src/port1.0/porttrace.tcl
r116781 r117751 67 67 set env(DYLD_INSERT_LIBRARIES) ${tracelib_path} 68 68 } 69 set env(DYLD_FORCE_FLAT_NAMESPACE) 170 69 set env(DARWINTRACE_LOG) "$trace_fifo" 71 70 # The sandbox is limited to: … … 171 170 if {${os.platform} == "darwin"} { 172 171 global env trace_fifo macosx_version 173 foreach var {DYLD_INSERT_LIBRARIES D YLD_FORCE_FLAT_NAMESPACE DARWINTRACE_LOG DARWINTRACE_SANDBOX_BOUNDS} {172 foreach var {DYLD_INSERT_LIBRARIES DARWINTRACE_LOG} { 174 173 array unset env $var 175 174 if {$macosx_version eq "10.5"} {
Note: See TracChangeset
for help on using the changeset viewer.