[darwinbuild-changes] [236] trunk/darwintrace/darwintrace.c

source_changes at macosforge.org source_changes at macosforge.org
Wed Oct 4 02:00:32 PDT 2006


Revision: 236
          http://trac.macosforge.org/projects/darwinbuild/changeset/236
Author:   ssen
Date:     2006-10-04 02:00:32 -0700 (Wed, 04 Oct 2006)

Log Message:
-----------
Trace readlink(2). Just like we don't log the contents of
opened files, we don't log the result of the readlink.
This is needed for things like Xcode readlink(2)ing /usr/bin/cc
and then calling /usr/bin/gcc-3.3 directly, bypassing the execve(2)
logging.

Modified Paths:
--------------
    trunk/darwintrace/darwintrace.c

Modified: trunk/darwintrace/darwintrace.c
===================================================================
--- trunk/darwintrace/darwintrace.c	2005-09-13 20:31:20 UTC (rev 235)
+++ trunk/darwintrace/darwintrace.c	2006-10-04 09:00:32 UTC (rev 236)
@@ -211,6 +211,33 @@
 	return result;
 }
 
+/* Log calls to readlink(2) into the file specified by DARWINTRACE_LOG.
+   Only logs if the DARWINTRACE_LOG environment variable is set.
+   Only logs files where the readlink succeeds.
+*/
+
+ssize_t  readlink(const char * path, char * buf, size_t bufsiz) {
+#define readlink(x,y,z) syscall(SYS_readlink, (x), (y), (z))
+	ssize_t result;
+
+	result = readlink(path, buf, bufsiz);
+	if (result >= 0) {
+	  __darwintrace_setup();
+	  if (__darwintrace_fd >= 0) {
+	    char realpath[MAXPATHLEN];
+
+	    dprintf("darwintrace: original readlink path is %s\n", path);
+
+	    strcpy(realpath, path);
+	    
+	    __darwintrace_cleanup_path(realpath);
+
+	    __darwintrace_logpath(__darwintrace_fd, NULL, "readlink", realpath);
+	  }
+	}
+	return result;
+}
+
 int execve(const char* path, char* const argv[], char* const envp[]) {
 #define execve(x,y,z) syscall(SYS_execve, (x), (y), (z))
 	int result;

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.macosforge.org/pipermail/darwinbuild-changes/attachments/20061004/3ec10e7f/attachment.html


More information about the darwinbuild-changes mailing list