Revision: 426 http://trac.macosforge.org/projects/darwinbuild/changeset/426 Author: wsiegrist@apple.com Date: 2008-12-02 19:32:23 -0800 (Tue, 02 Dec 2008) Log Message: ----------- Copy libSystem instead of rename when backing up files to avoid hang due to missing libSystem Modified Paths: -------------- branches/PR-6392966/darwinup/Depot.cpp Modified: branches/PR-6392966/darwinup/Depot.cpp =================================================================== --- branches/PR-6392966/darwinup/Depot.cpp 2008-12-02 22:01:46 UTC (rev 425) +++ branches/PR-6392966/darwinup/Depot.cpp 2008-12-03 03:32:23 UTC (rev 426) @@ -28,6 +28,7 @@ #include "Utils.h" #include <assert.h> +#include <copyfile.h> #include <errno.h> #include <fcntl.h> #include <libgen.h> @@ -421,8 +422,17 @@ ++context->files_modified; // XXX: res = file->backup() - IF_DEBUG("[backup] rename(%s, %s)\n", file->path(), dstpath); - res = rename(file->path(), dstpath); + + // Copy libSystem since it cannot be renamed safely + const char* libsystem = "/usr/lib/libSystem.B.dylib"; + if (strncmp(libsystem, file->path(), strlen(libsystem)) == 0) { + IF_DEBUG("[backup] copyfile(%s, %s)\n", file->path(), dstpath); + res = copyfile(file->path(), dstpath, NULL, COPYFILE_ALL); + } else { + IF_DEBUG("[backup] rename(%s, %s)\n", file->path(), dstpath); + res = rename(file->path(), dstpath); + } + if (res != 0) fprintf(stderr, "%s:%d: backup failed: %s: %s (%d)\n", __FILE__, __LINE__, dstpath, strerror(errno), errno); free(dstpath); }
participants (1)
-
source_changes@macosforge.org