How to write mmap input memory to O_DIRECT output file?
Posted
by
Friedrich
on Stack Overflow
See other posts from Stack Overflow
or by Friedrich
Published on 2011-06-22T18:31:23Z
Indexed on
2012/03/19
18:03 UTC
Read the original article
Hit count: 389
linux-kernel
|mmap
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
© Stack Overflow or respective owner