Skip to content
Permalink
Browse files

Return sooner from redirection is redirect is not set

git-svn-id: https://svn.macosforge.org/repository/darwinbuild/branches/PR-8817822@928 10a61168-4876-4dac-953b-31e694342555
  • Loading branch information
wsiegrist@apple.com
wsiegrist@apple.com committed Feb 8, 2011
1 parent 1ae1675 commit 8d4bca1b362c03c1b037730d5173c49b96ca9d5a
Showing with 6 additions and 4 deletions.
  1. +6 −4 darwintrace/darwintrace.c
@@ -101,17 +101,19 @@ static inline bool darwintrace_except(const char *str) {
}

/* apply redirection heuristic to path */
static inline char* darwintrace_redirect_path(const char* path) {
static inline char* darwintrace_redirect_path(const char* path) {
if (!darwintrace_redirect) return (char*)path;

char *redirpath;
redirpath = (char *)path;
if (darwintrace_redirect
&& path[0] == '/'
if (path[0] == '/'
&& !darwintrace_except(path)
&& strncmp(darwintrace_buildroot, path, strlen(darwintrace_buildroot))!=0
&& strncmp(darwintrace_redirect, path, strlen(darwintrace_redirect))!=0 ) {
asprintf(&redirpath, "%s%s%s", darwintrace_redirect, (*path == '/' ? "" : "/"), path);
dprintf("darwintrace: redirect %s -> %s\n", path, redirpath);
}

return redirpath;
}

@@ -228,7 +230,7 @@ int darwintrace_open(const char* path, int flags, ...) {
mode = va_arg(args, int);
va_end(args);
result = open(redirpath, flags, mode);
if (result >= 0 && (flags & (O_CREAT | O_WRONLY /*O_RDWR*/)) == 0 ) {
if (result >= 0 && (flags & (O_CREAT | O_WRONLY)) == 0 ) {
darwintrace_setup();
if (darwintrace_fd >= 0) {
char realpath[MAXPATHLEN];

0 comments on commit 8d4bca1

Please sign in to comment.
You can’t perform that action at this time.