caddr_t buf = mmap(0, len, PROT_READ | PROT_WRITE,
MAP_FILE | MAP_SHARED, ofd, 0);
mmap(buf, len, PROT_READ, MAP_FIXED | MAP_FILE |
MAP_SHARED, ifd, 0);
So the two mmap overlap and automatically copy
data. This has two drawbacks:
1) It requires us to specify the number of bytes
to be written and map this into our address
space (mapping could be a big problem with
large >1gb files).
2) It requires the kernel to search through
the memory map for the process, and check
for overlaps (possibly multiple!), whereas
sendfile can attach redirection information
directly to the FD structure.
mmap() does have significant overhead as Linus
pointed out, and sendfile looks more easily
flexible.
Zach Amsden
amsden@andrew.cmu.edu
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu