why doesn't following pseudo-code work (O_DIRECT results in EFAULT)
in_fd = open("/dev/mem");
in_mmap = mmap(in_fd);
out_fd = open("/tmp/file", O_DIRECT);
write(out_fd, in_mmap, PAGE_SIZE);
while following does (no O_DIRECT)
in_fd = open("/dev/mem");
in_mmap = mmap(in_fd);
out_fd = open("/tmp/file");
write(out_fd, in_mmap, PAGE_SIZE);
I guess it's something with virtual kernel pages to virtual user pages, which cannot be translated in the write call?
Best regards,
Friedrich
O_DIRECT
writes need to pin the pages; maybe that is the problem... What are you actually trying to do? If this is a memory-mapped hardware device, you might be better off addingsplice
support to the driver... Also, please provide a more complete example (including all flags to all system calls). Ideally one that anybody could compile and run to reproduce. – Wesla