--- valgrind-3.6.0/coregrind/m_libcfile.c	2010-10-20 16:19:45.000000000 -0400
+++ valgrind-3.6.0-pasha/coregrind/m_libcfile.c	2011-03-15 15:48:15.296244000 -0400
@@ -603,6 +603,7 @@
    Int    n, tries, fd;
    UInt   seed;
    SysRes sres;
+   char *vg_tmp_path;
 
    vg_assert(part_of_name);
    n = VG_(strlen)(part_of_name);
@@ -614,8 +615,12 @@
    while (True) {
       if (tries > 10) 
          return -1;
-      VG_(sprintf)( buf, "/tmp/valgrind_%s_%08x", 
-                         part_of_name, VG_(random)( &seed ));
+      /* Check if user specified alternative tmp */
+      vg_tmp_path = VG_(getenv)("VALGRIND_TMP_PATH");
+      if (NULL == vg_tmp_path)
+          vg_tmp_path = "/tmp";
+      VG_(sprintf)( buf, "%s/valgrind_%s_%08x", 
+                         vg_tmp_path, part_of_name, VG_(random)( &seed ));
       if (0)
          VG_(printf)("VG_(mkstemp): trying: %s\n", buf);
 
