mirror of
https://git.mirrors.martin98.com/https://github.com/slic3r/Slic3r.git
synced 2025-08-13 17:29:03 +08:00
debug log in copy_file_linux
This commit is contained in:
parent
7b506bc3cf
commit
d6084621b2
@ -443,6 +443,8 @@ bool copy_file_linux(const boost::filesystem::path &from, const boost::filesyste
|
|||||||
ec.clear();
|
ec.clear();
|
||||||
int err = 0;
|
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
|
// 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;
|
fd_wrapper infile, outfile;
|
||||||
|
|
||||||
@ -458,6 +460,8 @@ bool copy_file_linux(const boost::filesystem::path &from, const boost::filesyste
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
BOOST_LOG_TRIVIAL(trace) << "infile.fd";
|
||||||
|
|
||||||
|
|
||||||
struct ::stat from_stat;
|
struct ::stat from_stat;
|
||||||
if (::fstat(infile.fd, &from_stat) != 0) {
|
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;
|
err = errno;
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BOOST_LOG_TRIVIAL(trace) << "from_stat";
|
||||||
|
|
||||||
const mode_t from_mode = from_stat.st_mode;
|
const mode_t from_mode = from_stat.st_mode;
|
||||||
if (!S_ISREG(from_mode)) {
|
if (!S_ISREG(from_mode)) {
|
||||||
@ -472,6 +478,8 @@ bool copy_file_linux(const boost::filesystem::path &from, const boost::filesyste
|
|||||||
goto fail;
|
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,
|
// 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.
|
// 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;
|
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;
|
break;
|
||||||
}
|
}
|
||||||
|
BOOST_LOG_TRIVIAL(trace) << "outfile.fd";
|
||||||
|
|
||||||
struct ::stat to_stat;
|
struct ::stat to_stat;
|
||||||
if (::fstat(outfile.fd, &to_stat) != 0)
|
if (::fstat(outfile.fd, &to_stat) != 0)
|
||||||
goto fail_errno;
|
goto fail_errno;
|
||||||
|
|
||||||
|
BOOST_LOG_TRIVIAL(trace) << "to_stat";
|
||||||
|
|
||||||
to_mode = to_stat.st_mode;
|
to_mode = to_stat.st_mode;
|
||||||
if (!S_ISREG(to_mode)) {
|
if (!S_ISREG(to_mode)) {
|
||||||
err = ENOSYS;
|
err = ENOSYS;
|
||||||
goto fail;
|
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) {
|
if (from_stat.st_dev == to_stat.st_dev && from_stat.st_ino == to_stat.st_ino) {
|
||||||
err = EEXIST;
|
err = EEXIST;
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BOOST_LOG_TRIVIAL(trace) << "from / to compare";
|
||||||
|
|
||||||
//! copy_file implementation that uses sendfile loop. Requires sendfile to support file descriptors.
|
//! 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.
|
//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
|
// 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,
|
// 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.
|
// we may need to update its mode bits to match the source file.
|
||||||
if (to_mode != from_mode && ::fchmod(outfile.fd, from_mode) != 0) {
|
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)
|
if (err != 0)
|
||||||
goto fail_errno;
|
goto fail_errno;
|
||||||
|
|
||||||
|
BOOST_LOG_TRIVIAL(trace) << "copy_file_linux success";
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
#endif // __linux__
|
#endif // __linux__
|
||||||
|
Loading…
x
Reference in New Issue
Block a user