title: How to write mmap input memory to O_DIRECT output file?
body: <p>why doesn't following pseudo-code work (O_DIRECT results in EFAULT)</p>
  
  <pre><code>in_fd = open("/dev/mem");
  in_mmap = mmap(in_fd);
  out_fd = open("/tmp/file", O_DIRECT);
  write(out_fd, in_mmap, PAGE_SIZE);
  </code></pre>
  
  <p>while following does (no O_DIRECT)</p>
  
  <pre><code>in_fd = open("/dev/mem");
  in_mmap = mmap(in_fd);
  out_fd = open("/tmp/file");
  write(out_fd, in_mmap, PAGE_SIZE);
  </code></pre>
  
  <p>I guess it's something with virtual kernel pages to virtual user pages, which cannot be translated in the write call?</p>
  
  <p>Best regards,</p>
  
  <p>Friedrich</p>