[llvm] r358634 - Revert Implement sys::fs::copy_file using the macOS copyfile(3) API to support APFS clones.

Adrian Prantl via llvm-commits llvm-commits at lists.llvm.org
Wed Apr 17 18:21:10 PDT 2019


Author: adrian
Date: Wed Apr 17 18:21:10 2019
New Revision: 358634

URL: http://llvm.org/viewvc/llvm-project?rev=358634&view=rev
Log:
Revert Implement sys::fs::copy_file using the macOS copyfile(3) API to support APFS clones.

This reverts r358628 (git commit 91a06bee788262a294527b815354f380d99dfa9b)
while investigating a crash reproducer bot failure.

Modified:
    llvm/trunk/lib/Support/Path.cpp
    llvm/trunk/lib/Support/Unix/Path.inc

Modified: llvm/trunk/lib/Support/Path.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/Path.cpp?rev=358634&r1=358633&r2=358634&view=diff
==============================================================================
--- llvm/trunk/lib/Support/Path.cpp (original)
+++ llvm/trunk/lib/Support/Path.cpp Wed Apr 17 18:21:10 2019
@@ -935,7 +935,6 @@ std::error_code create_directories(const
   return create_directory(P, IgnoreExisting, Perms);
 }
 
-#ifndef __APPLE__
 static std::error_code copy_file_internal(int ReadFD, int WriteFD) {
   const size_t BufSize = 4096;
   char *Buf = new char[BufSize];
@@ -989,7 +988,6 @@ std::error_code copy_file(const Twine &F
 
   return EC;
 }
-#endif
 
 ErrorOr<MD5::MD5Result> md5_contents(int FD) {
   MD5 Hash;

Modified: llvm/trunk/lib/Support/Unix/Path.inc
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/Unix/Path.inc?rev=358634&r1=358633&r2=358634&view=diff
==============================================================================
--- llvm/trunk/lib/Support/Unix/Path.inc (original)
+++ llvm/trunk/lib/Support/Unix/Path.inc Wed Apr 17 18:21:10 2019
@@ -37,7 +37,6 @@
 #ifdef __APPLE__
 #include <mach-o/dyld.h>
 #include <sys/attr.h>
-#include <copyfile.h>
 #elif defined(__DragonFly__)
 #include <sys/mount.h>
 #endif
@@ -1114,55 +1113,5 @@ void system_temp_directory(bool ErasedOn
 
 } // end namespace path
 
-namespace fs {
-
-#ifdef __APPLE__
-/// This implementation tries to perform an APFS CoW clone of the file,
-/// which can be much faster and uses less space.
-std::error_code copy_file(const Twine &From, const Twine &To) {
-  uint32_t Flag = COPYFILE_DATA;
-  bool IsSymlink;
-  if (std::error_code Error = is_symlink_file(From, IsSymlink))
-    return Error;
-
-  if (!IsSymlink)
-    if (__builtin_available(macos 10.12, *))
-      Flag = COPYFILE_CLONE;
-
-  int Status =
-      copyfile(From.str().c_str(), To.str().c_str(), /* State */ NULL, Flag);
-
-  if (Status == 0)
-    return std::error_code();
-  return std::error_code(errno, std::generic_category());
-}
-
-/// This implementation tries to perform an APFS CoW clone of the file,
-/// which can be much faster and uses less space.
-std::error_code copy_file(const Twine &From, int ToFD) {
-  uint32_t Flag = COPYFILE_DATA;
-  bool IsSymlink;
-  if (std::error_code Error = is_symlink_file(From, IsSymlink))
-    return Error;
-
-  int ReadFD;
-  if (std::error_code EC = openFileForRead(From, ReadFD, OF_None))
-    return EC;
-
-  if (!IsSymlink)
-    if (__builtin_available(macos 10.12, *))
-      Flag = COPYFILE_CLONE;
-
-  int Status = fcopyfile(ReadFD, ToFD, /*State*/ NULL, Flag);
-
-  close(ReadFD);
-  if (Status == 0)
-    return std::error_code();
-  return std::error_code(errno, std::generic_category());
-}
-#endif
-
-} // end namespace fs
-
 } // end namespace sys
 } // end namespace llvm




More information about the llvm-commits mailing list