{
  "$type": "site.standard.document",
  "bskyPostRef": {
    "cid": "bafyreib4w2lrd5ujjpuxzyowuikafbneqpbvjjhdemqs6d55cw4wmmviry",
    "uri": "at://did:plc:ivbknywyskln22er3nkssdhl/app.bsky.feed.post/3mhefp63qyxk2"
  },
  "path": "/t/idea-add-an-option-to-set-the-mode-to-fs-copy/24080#post_13",
  "publishedAt": "2026-03-18T15:55:13.000Z",
  "site": "https://internals.rust-lang.org",
  "textContent": "`splice` only works if at least one of the specified file descriptors refers to a pipe – it won't be able to copy between two regular files on unrelated filesystems.\n\nIt would be possible to implement a copy by splicing from one file to the other via a pipe (which may require several system calls because a pipe has a limited capacity). I don't know how this compares performance-wise with a manual copy (although I'd expect it to be a bit faster).\n\nAnother option is `sendfile`, which (in recent kernels) has the restriction that the file being copied from is mmap-able (or that the call can be desugared into `splice`). This would be able to handle almost all combinations of files, but not quite all of them (e.g. if both the input and output are sockets, none of `sendfile`, `splice` or `copy_file_range` would work).",
  "title": "Idea: Add an option to set the mode to fs::copy"
}