Results 1 to 7 of 7
http://en.wikipedia.org/wiki/Splice_(system_call ) has a code example where spice() is used to copy one file to another. A pipe (through a pipe() call) acts as a buffer between them, so that ...
- 01-29-2009 #1Just Joined!
- Join Date
- Jan 2009
- Location
- Montreal, Canada
- Posts
- 4
Using in-kernel tool to copy one file to another
http://en.wikipedia.org/wiki/Splice_(system_call) has a code example where spice() is used to copy one file to another. A pipe (through a pipe() call) acts as a buffer between them, so that each call to splice() has a descriptor to a pipe. I have a couple of problems with this. One is that I find it strange that the pipe is loaded with the entire file first, and only then does the program being unloading it. Another is that I've been told that it is inappropriate to be using a pipe for this purpose at all, and that sendfile() is the proper in-kernel way to copy one file to another--although, the current Linux kernel is buggy, so that is not possible right now. Is all this correct?
Does this mean that the most efficient way to copy one file to another is to use the good ol' user space read() and write() calls?
- 01-29-2009 #2
try - man splice
the "notes section" gives a good explanation of this system call...
so according to this splice is more efficient in its execution...Though we talk of copying, actual copies are generally avoided. The
kernel does this by implementing a pipe buffer as a set of reference-
counted pointers to pages of kernel memory. The kernel creates
"copies" of pages in a buffer by creating new pointers (for the output
buffer) referring to the pages, and increasing the reference counts for
the pages: only pointers are copied, not the pages of the buffer.
or check this discussion:
question about splice performance - Unix Linux Forum
- 01-30-2009 #3Just Joined!
- Join Date
- Jan 2009
- Location
- Montreal, Canada
- Posts
- 4
So what are you saying? That the code example is the right way of doing things?
- 01-30-2009 #4
What coded example are you talking about...
- 01-30-2009 #5Just Joined!
- Join Date
- Jan 2009
- Location
- Montreal, Canada
- Posts
- 4
The one on the page I linked in my OP
- 01-30-2009 #6
Like I said what coded example...did you check your link...
- 01-30-2009 #7Just Joined!
- Join Date
- Jan 2009
- Location
- Montreal, Canada
- Posts
- 4
The URL is right, but the link that the forum made is wrong. The link missed the ')' at the end. I was able to get there by clicking the link, going to the 404 page, then adding the ')' to the end of the URL in my address bar.


Reply With Quote
