if (result >= 0 && (flags & (O_CREAT | O_WRONLY )) == 0 ) { __darwintrace_setup(); if (__darwintrace_fd >= 0) { int size; if(strncmp(path, "/.vol/", 6) == 0) { char realpath[MAXPATHLEN]; if(0 == fcntl(result, F_GETPATH, realpath)) { #if DARWINTRACE_SHOW_PROCESS size = snprintf(__darwintrace_buf, BUFFER_SIZE, "%s[%d]\topen\t%s\n", __darwintrace_progname, __darwintrace_pid, realpath );  #else size = snprintf(__darwintrace_buf, BUFFER_SIZE, "open\t%s\n", realpath );
if (result >= 0) {  struct stat sb; fstat(result, &sb); if ((sb.st_mode & S_IFDIR) == 0) { if ((flags & (O_CREAT | O_WRONLY )) == 0 ) { __darwintrace_setup(); if (__darwintrace_fd >= 0) { log_op("open", path, result); } #if DARWINTRACE_LOG_CREATE } else if (flags & O_CREAT) { __darwintrace_setup(); if (__darwintrace_fd >= 0) { log_op("create", path, result); }
int open(const char* path, int flags, ...) {#define open(x,y,z) syscall(SYS_open, (x), (y), (z))	mode_t mode;	int result;	va_list args;	va_start(args, flags);	mode = va_arg(args, int);	va_end(args);	result = open(path, flags, mode);	if (result >= 0 && (flags & (O_CREAT | O_WRONLY /*O_RDWR*/)) == 0 ) {		__darwintrace_setup();		if (__darwintrace_fd >= 0) {		  int size;		  if(strncmp(path, "/.vol/", 6) == 0) {		    char realpath[MAXPATHLEN];		    if(0 == fcntl(result, F_GETPATH, realpath)) {#if DARWINTRACE_SHOW_PROCESS		      size = snprintf(__darwintrace_buf, BUFFER_SIZE, "%s[%d]\topen\t%s\n", __darwintrace_progname, __darwintrace_pid, realpath );		      /* printf("resolved %s to %s\n", path, realpath); */#else		      size = snprintf(__darwintrace_buf, BUFFER_SIZE, "open\t%s\n", realpath );#endif		    } else {		    /* if we can't resolve it, ignore the volfs path */		      size = 0;		    }		  } else {#if DARWINTRACE_SHOW_PROCESS		    size = snprintf(__darwintrace_buf, BUFFER_SIZE, "%s[%d]\topen\t%s\n", __darwintrace_progname, __darwintrace_pid, path );#else			size = snprintf(__darwintrace_buf, BUFFER_SIZE, "open\t%s\n", path );#endif		  }		  write(__darwintrace_fd, __darwintrace_buf, size);		  fsync(__darwintrace_fd);		}	}	return result;}