[libcxx-commits] [PATCH] D60880: [libc++] Use COPYFILE_CLONE from the macOS copyfile(3) API to support APFS clones

Louis Dionne via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Thu Apr 18 11:03:46 PDT 2019


ldionne created this revision.
ldionne added a reviewer: EricWF.
Herald added subscribers: libcxx-commits, dexonsmith, jkorous, christof.
Herald added a project: libc++.

On macOS, copyfile supports cloning files instead of copying them, which
is more efficient. This is a best effort flag -- if cloning can't be
performed, it falls back to a normal copy of the file. The idea for this
patch comes from https://reviews.llvm.org/D60802.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D60880

Files:
  libcxx/src/filesystem/operations.cpp


Index: libcxx/src/filesystem/operations.cpp
===================================================================
--- libcxx/src/filesystem/operations.cpp
+++ libcxx/src/filesystem/operations.cpp
@@ -678,7 +678,7 @@
   };
 
   CopyFileState cfs;
-  if (fcopyfile(read_fd.fd, write_fd.fd, cfs.state, COPYFILE_DATA) < 0) {
+  if (fcopyfile(read_fd.fd, write_fd.fd, cfs.state, COPYFILE_CLONE) < 0) {
     ec = capture_errno();
     return false;
   }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D60880.195787.patch
Type: text/x-patch
Size: 446 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20190418/388ce415/attachment.bin>


More information about the libcxx-commits mailing list