views:

58

answers:

1

Hello

Can sendfile() linux syscall be used to send part of file from one mmaped file to other mmaped file?

+3  A: 

From sendfile(2):

Presently (Linux 2.6.9): in_fd, must correspond to a file which supports mmap()-like operations (i.e., it cannot be a socket); and out_fd must refer to a socket.

So it looks like the answer is no.

Edit

I think I understand what you are looking for now. Check out splice(2).

Nikolai N Fetissov
But what with more recent kernels? mans in linux are maintained very bad (comparing with any commercial unix, line solaris, hpux, etc)
osgx
I don't think that has changed, have to look into the source, but the question I forgot to ask - what are you trying to do? Can't you solve this with shared memory? Or was it just curiosity?
Nikolai N Fetissov
I want to do zerocopy. memcpy is too slow.
osgx
If this is on the same box, just work with shared pages from multiple processes. Something has to write to memory and then something has to read from it in any case.
Nikolai N Fetissov
I cant mark entire process memory as shared.
osgx