diff options
author | David Kocik <kocikdav@gmail.com> | 2021-06-11 12:46:19 +0300 |
---|---|---|
committer | David Kocik <kocikdav@gmail.com> | 2021-06-17 11:52:15 +0300 |
commit | d6084621b2aa0fde914948dfb15e8d2ed2885049 (patch) | |
tree | 5a4947fbfda10e70acff9d014e5a3d0ece5c662b /src/libslic3r/utils.cpp | |
parent | 7b506bc3cf4b5697e2b2d4a0ec5946d805a99d13 (diff) |
debug log in copy_file_linux
Diffstat (limited to 'src/libslic3r/utils.cpp')
-rw-r--r-- | src/libslic3r/utils.cpp | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/src/libslic3r/utils.cpp b/src/libslic3r/utils.cpp index 1ac45f1b5..719d2f6fb 100644 --- a/src/libslic3r/utils.cpp +++ b/src/libslic3r/utils.cpp @@ -443,6 +443,8 @@ bool copy_file_linux(const boost::filesystem::path &from, const boost::filesyste ec.clear(); int err = 0; + BOOST_LOG_TRIVIAL(trace) << "copy_file_linux("<<from<<", "<<to<< ")"; + // Note: Declare fd_wrappers here so that errno is not clobbered by close() that may be called in fd_wrapper destructors fd_wrapper infile, outfile; @@ -458,6 +460,8 @@ bool copy_file_linux(const boost::filesystem::path &from, const boost::filesyste } break; } + BOOST_LOG_TRIVIAL(trace) << "infile.fd"; + struct ::stat from_stat; if (::fstat(infile.fd, &from_stat) != 0) { @@ -465,6 +469,8 @@ bool copy_file_linux(const boost::filesystem::path &from, const boost::filesyste err = errno; goto fail; } + + BOOST_LOG_TRIVIAL(trace) << "from_stat"; const mode_t from_mode = from_stat.st_mode; if (!S_ISREG(from_mode)) { @@ -472,6 +478,8 @@ bool copy_file_linux(const boost::filesystem::path &from, const boost::filesyste goto fail; } + BOOST_LOG_TRIVIAL(trace) << "from_mode"; + // Enable writing for the newly created files. Having write permission set is important e.g. for NFS, // which checks the file permission on the server, even if the client's file descriptor supports writing. mode_t to_mode = from_mode | S_IWUSR; @@ -487,22 +495,29 @@ bool copy_file_linux(const boost::filesystem::path &from, const boost::filesyste } break; } + BOOST_LOG_TRIVIAL(trace) << "outfile.fd"; struct ::stat to_stat; if (::fstat(outfile.fd, &to_stat) != 0) goto fail_errno; + BOOST_LOG_TRIVIAL(trace) << "to_stat"; + to_mode = to_stat.st_mode; if (!S_ISREG(to_mode)) { err = ENOSYS; goto fail; } + BOOST_LOG_TRIVIAL(trace) << "to_mode"; + if (from_stat.st_dev == to_stat.st_dev && from_stat.st_ino == to_stat.st_ino) { err = EEXIST; goto fail; } + BOOST_LOG_TRIVIAL(trace) << "from / to compare"; + //! copy_file implementation that uses sendfile loop. Requires sendfile to support file descriptors. //FIXME Vojtech: This is a copy loop valid for Linux 2.6.33 and newer. // copy_file_data_copy_file_range() supports cross-filesystem copying since 5.3, but Vojtech did not want to polute this @@ -530,6 +545,8 @@ bool copy_file_linux(const boost::filesystem::path &from, const boost::filesyste } } + BOOST_LOG_TRIVIAL(trace) << "sendfile loop"; + // If we created a new file with an explicitly added S_IWUSR permission, // we may need to update its mode bits to match the source file. if (to_mode != from_mode && ::fchmod(outfile.fd, from_mode) != 0) { @@ -553,6 +570,8 @@ bool copy_file_linux(const boost::filesystem::path &from, const boost::filesyste if (err != 0) goto fail_errno; + BOOST_LOG_TRIVIAL(trace) << "copy_file_linux success"; + return true; } #endif // __linux__ |