title: open() fails to open files
body: <p>For some reason I can't get open() to open a file. Here's my code.</p>
  
  <pre><code>static int context_ctor(X86Context *ctx)
  {
      char file[512];
      memset(ctx, 0, sizeof(X86Context));
  
      sprintf(file, "%s.%d", "test", getpid());
  
      ctx-&gt;fp = open(file, O_RDWR);
  
      if(ctx-&gt;fp &lt; 0) {
          printf("errno %d %s\n", errno, file);
          return VISUAL_ERROR_GENERAL;
      }
  
      ctx-&gt;buf = mmap(0, MAXFILESIZE, PROT_READ | PROT_WRITE | PROT_EXEC, MAP_PRIVATE, ctx-&gt;fp, 0);
  
      printf("context_ctor: %p\n", ctx-&gt;buf);
  
      close(ctx-&gt;fp);
      exit(0);
  }
  </code></pre>
  
  <p>And here's the output:</p>
  
  <pre><code>errno 2 test.12356
  </code></pre>
  
  <p>Looking up the error code reveals: </p>
  
  <pre><code>[EACCES]
      Permission denied.
  </code></pre>
  
  <p>I know I have permission to read/write/execute files in this directory. I even tried /tmp/test.pid. Any idea?</p>