Find the answer to your Linux question:
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 ...
  1. #1
    Just 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?

  2. #2
    Linux Enthusiast gerard4143's Avatar
    Join Date
    Dec 2007
    Location
    Canada, Prince Edward Island
    Posts
    714
    Quote Originally Posted by Angus View Post
    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?
    try - man splice

    the "notes section" gives a good explanation of this system call...

    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.
    so according to this splice is more efficient in its execution...

    or check this discussion:

    question about splice performance - Unix Linux Forum

  3. #3
    Just 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?

  4. #4
    Linux Enthusiast gerard4143's Avatar
    Join Date
    Dec 2007
    Location
    Canada, Prince Edward Island
    Posts
    714
    What coded example are you talking about...

  5. #5
    Just Joined!
    Join Date
    Jan 2009
    Location
    Montreal, Canada
    Posts
    4
    The one on the page I linked in my OP

  6. #6
    Linux Enthusiast gerard4143's Avatar
    Join Date
    Dec 2007
    Location
    Canada, Prince Edward Island
    Posts
    714
    Like I said what coded example...did you check your link...

  7. #7
    Just 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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...