Loading adb/client/file_sync_client.cpp +3 −9 Original line number Diff line number Diff line Loading @@ -681,9 +681,7 @@ static bool sync_send(SyncConnection& sc, const char* lpath, const char* rpath, if (sync) { struct stat st; if (sync_lstat(sc, rpath, &st)) { // For links, we cannot update the atime/mtime. if ((S_ISREG(mode & st.st_mode) && st.st_mtime == static_cast<time_t>(mtime)) || (S_ISLNK(mode & st.st_mode) && st.st_mtime >= static_cast<time_t>(mtime))) { if (st.st_mtime == static_cast<time_t>(mtime)) { sc.RecordFilesSkipped(1); return true; } Loading Loading @@ -921,16 +919,12 @@ static bool copy_local_dir_remote(SyncConnection& sc, std::string lpath, for (copyinfo& ci : file_list) { struct stat st; if (sc.FinishStat(&st)) { if (st.st_size == static_cast<off_t>(ci.size)) { // For links, we cannot update the atime/mtime. if ((S_ISREG(ci.mode & st.st_mode) && st.st_mtime == ci.time) || (S_ISLNK(ci.mode & st.st_mode) && st.st_mtime >= ci.time)) { if (st.st_size == static_cast<off_t>(ci.size) && st.st_mtime == ci.time) { ci.skip = true; } } } } } sc.ComputeExpectedTotalBytes(file_list); Loading adb/daemon/file_sync_service.cpp +41 −25 Original line number Diff line number Diff line Loading @@ -27,6 +27,7 @@ #include <string.h> #include <sys/mount.h> #include <sys/stat.h> #include <sys/time.h> #include <sys/types.h> #include <unistd.h> #include <utime.h> Loading Loading @@ -242,10 +243,10 @@ static bool SendSyncFailErrno(int fd, const std::string& reason) { return SendSyncFail(fd, StringPrintf("%s: %s", reason.c_str(), strerror(errno))); } static bool handle_send_file(int s, const char* path, uid_t uid, gid_t gid, uint64_t capabilities, mode_t mode, std::vector<char>& buffer, bool do_unlink) { static bool handle_send_file(int s, const char* path, uint32_t* timestamp, uid_t uid, gid_t gid, uint64_t capabilities, mode_t mode, std::vector<char>& buffer, bool do_unlink) { syncmsg msg; unsigned int timestamp = 0; __android_log_security_bswrite(SEC_TAG_ADB_SEND_FILE, path); Loading Loading @@ -291,7 +292,7 @@ static bool handle_send_file(int s, const char* path, uid_t uid, gid_t gid, uint if (msg.data.id != ID_DATA) { if (msg.data.id == ID_DONE) { timestamp = msg.data.size; *timestamp = msg.data.size; break; } SendSyncFail(s, "invalid data message"); Loading @@ -316,11 +317,6 @@ static bool handle_send_file(int s, const char* path, uid_t uid, gid_t gid, uint goto fail; } utimbuf u; u.actime = timestamp; u.modtime = timestamp; utime(path, &u); msg.status.id = ID_OKAY; msg.status.msglen = 0; return WriteFdExactly(s, &msg.status, sizeof(msg.status)); Loading Loading @@ -360,9 +356,12 @@ abort: } #if defined(_WIN32) extern bool handle_send_link(int s, const std::string& path, std::vector<char>& buffer) __attribute__((error("no symlinks on Windows"))); extern bool handle_send_link(int s, const std::string& path, uint32_t* timestamp, std::vector<char>& buffer) __attribute__((error("no symlinks on Windows"))); #else static bool handle_send_link(int s, const std::string& path, std::vector<char>& buffer) { static bool handle_send_link(int s, const std::string& path, uint32_t* timestamp, std::vector<char>& buffer) { syncmsg msg; if (!ReadFdExactly(s, &msg.data, sizeof(msg.data))) return false; Loading Loading @@ -399,6 +398,7 @@ static bool handle_send_link(int s, const std::string& path, std::vector<char>& if (!ReadFdExactly(s, &msg.data, sizeof(msg.data))) return false; if (msg.data.id == ID_DONE) { *timestamp = msg.data.size; msg.status.id = ID_OKAY; msg.status.msglen = 0; if (!WriteFdExactly(s, &msg.status, sizeof(msg.status))) return false; Loading Loading @@ -448,10 +448,11 @@ static bool do_send(int s, const std::string& spec, std::vector<char>& buffer) { adb_unlink(path.c_str()); } bool result; uint32_t timestamp; if (S_ISLNK(mode)) { return handle_send_link(s, path.c_str(), buffer); } result = handle_send_link(s, path.c_str(), ×tamp, buffer); } else { // Copy user permission bits to "group" and "other" permissions. mode &= 0777; mode |= ((mode >> 3) & 0070); Loading @@ -465,7 +466,22 @@ static bool do_send(int s, const std::string& spec, std::vector<char>& buffer) { fs_config(path.c_str(), 0, nullptr, &uid, &gid, &broken_api_hack, &capabilities); mode = broken_api_hack; } return handle_send_file(s, path.c_str(), uid, gid, capabilities, mode, buffer, do_unlink); result = handle_send_file(s, path.c_str(), ×tamp, uid, gid, capabilities, mode, buffer, do_unlink); } if (!result) { return false; } struct timeval tv[2]; tv[0].tv_sec = timestamp; tv[0].tv_usec = 0; tv[1].tv_sec = timestamp; tv[1].tv_usec = 0; lutimes(path.c_str(), tv); return true; } static bool do_recv(int s, const char* path, std::vector<char>& buffer) { Loading adb/transport.cpp +8 −2 Original line number Diff line number Diff line Loading @@ -71,6 +71,7 @@ const char* const kFeaturePushSync = "push_sync"; const char* const kFeatureApex = "apex"; const char* const kFeatureFixedPushMkdir = "fixed_push_mkdir"; const char* const kFeatureAbb = "abb"; const char* const kFeatureFixedPushSymlinkTimestamp = "fixed_push_symlink_timestamp"; namespace { Loading Loading @@ -1005,8 +1006,13 @@ size_t atransport::get_max_payload() const { const FeatureSet& supported_features() { // Local static allocation to avoid global non-POD variables. static const FeatureSet* features = new FeatureSet{ kFeatureShell2, kFeatureCmd, kFeatureStat2, kFeatureFixedPushMkdir, kFeatureApex, kFeatureAbb, kFeatureShell2, kFeatureCmd, kFeatureStat2, kFeatureFixedPushMkdir, kFeatureApex, kFeatureAbb, kFeatureFixedPushSymlinkTimestamp, // Increment ADB_SERVER_VERSION when adding a feature that adbd needs // to know about. Otherwise, the client can be stuck running an old // version of the server even after upgrading their copy of adb. Loading adb/transport.h +2 −0 Original line number Diff line number Diff line Loading @@ -67,6 +67,8 @@ extern const char* const kFeatureApex; extern const char* const kFeatureFixedPushMkdir; // adbd supports android binder bridge (abb). extern const char* const kFeatureAbb; // adbd properly updates symlink timestamps on push. extern const char* const kFeatureFixedPushSymlinkTimestamp; TransportId NextTransportId(); Loading Loading
adb/client/file_sync_client.cpp +3 −9 Original line number Diff line number Diff line Loading @@ -681,9 +681,7 @@ static bool sync_send(SyncConnection& sc, const char* lpath, const char* rpath, if (sync) { struct stat st; if (sync_lstat(sc, rpath, &st)) { // For links, we cannot update the atime/mtime. if ((S_ISREG(mode & st.st_mode) && st.st_mtime == static_cast<time_t>(mtime)) || (S_ISLNK(mode & st.st_mode) && st.st_mtime >= static_cast<time_t>(mtime))) { if (st.st_mtime == static_cast<time_t>(mtime)) { sc.RecordFilesSkipped(1); return true; } Loading Loading @@ -921,16 +919,12 @@ static bool copy_local_dir_remote(SyncConnection& sc, std::string lpath, for (copyinfo& ci : file_list) { struct stat st; if (sc.FinishStat(&st)) { if (st.st_size == static_cast<off_t>(ci.size)) { // For links, we cannot update the atime/mtime. if ((S_ISREG(ci.mode & st.st_mode) && st.st_mtime == ci.time) || (S_ISLNK(ci.mode & st.st_mode) && st.st_mtime >= ci.time)) { if (st.st_size == static_cast<off_t>(ci.size) && st.st_mtime == ci.time) { ci.skip = true; } } } } } sc.ComputeExpectedTotalBytes(file_list); Loading
adb/daemon/file_sync_service.cpp +41 −25 Original line number Diff line number Diff line Loading @@ -27,6 +27,7 @@ #include <string.h> #include <sys/mount.h> #include <sys/stat.h> #include <sys/time.h> #include <sys/types.h> #include <unistd.h> #include <utime.h> Loading Loading @@ -242,10 +243,10 @@ static bool SendSyncFailErrno(int fd, const std::string& reason) { return SendSyncFail(fd, StringPrintf("%s: %s", reason.c_str(), strerror(errno))); } static bool handle_send_file(int s, const char* path, uid_t uid, gid_t gid, uint64_t capabilities, mode_t mode, std::vector<char>& buffer, bool do_unlink) { static bool handle_send_file(int s, const char* path, uint32_t* timestamp, uid_t uid, gid_t gid, uint64_t capabilities, mode_t mode, std::vector<char>& buffer, bool do_unlink) { syncmsg msg; unsigned int timestamp = 0; __android_log_security_bswrite(SEC_TAG_ADB_SEND_FILE, path); Loading Loading @@ -291,7 +292,7 @@ static bool handle_send_file(int s, const char* path, uid_t uid, gid_t gid, uint if (msg.data.id != ID_DATA) { if (msg.data.id == ID_DONE) { timestamp = msg.data.size; *timestamp = msg.data.size; break; } SendSyncFail(s, "invalid data message"); Loading @@ -316,11 +317,6 @@ static bool handle_send_file(int s, const char* path, uid_t uid, gid_t gid, uint goto fail; } utimbuf u; u.actime = timestamp; u.modtime = timestamp; utime(path, &u); msg.status.id = ID_OKAY; msg.status.msglen = 0; return WriteFdExactly(s, &msg.status, sizeof(msg.status)); Loading Loading @@ -360,9 +356,12 @@ abort: } #if defined(_WIN32) extern bool handle_send_link(int s, const std::string& path, std::vector<char>& buffer) __attribute__((error("no symlinks on Windows"))); extern bool handle_send_link(int s, const std::string& path, uint32_t* timestamp, std::vector<char>& buffer) __attribute__((error("no symlinks on Windows"))); #else static bool handle_send_link(int s, const std::string& path, std::vector<char>& buffer) { static bool handle_send_link(int s, const std::string& path, uint32_t* timestamp, std::vector<char>& buffer) { syncmsg msg; if (!ReadFdExactly(s, &msg.data, sizeof(msg.data))) return false; Loading Loading @@ -399,6 +398,7 @@ static bool handle_send_link(int s, const std::string& path, std::vector<char>& if (!ReadFdExactly(s, &msg.data, sizeof(msg.data))) return false; if (msg.data.id == ID_DONE) { *timestamp = msg.data.size; msg.status.id = ID_OKAY; msg.status.msglen = 0; if (!WriteFdExactly(s, &msg.status, sizeof(msg.status))) return false; Loading Loading @@ -448,10 +448,11 @@ static bool do_send(int s, const std::string& spec, std::vector<char>& buffer) { adb_unlink(path.c_str()); } bool result; uint32_t timestamp; if (S_ISLNK(mode)) { return handle_send_link(s, path.c_str(), buffer); } result = handle_send_link(s, path.c_str(), ×tamp, buffer); } else { // Copy user permission bits to "group" and "other" permissions. mode &= 0777; mode |= ((mode >> 3) & 0070); Loading @@ -465,7 +466,22 @@ static bool do_send(int s, const std::string& spec, std::vector<char>& buffer) { fs_config(path.c_str(), 0, nullptr, &uid, &gid, &broken_api_hack, &capabilities); mode = broken_api_hack; } return handle_send_file(s, path.c_str(), uid, gid, capabilities, mode, buffer, do_unlink); result = handle_send_file(s, path.c_str(), ×tamp, uid, gid, capabilities, mode, buffer, do_unlink); } if (!result) { return false; } struct timeval tv[2]; tv[0].tv_sec = timestamp; tv[0].tv_usec = 0; tv[1].tv_sec = timestamp; tv[1].tv_usec = 0; lutimes(path.c_str(), tv); return true; } static bool do_recv(int s, const char* path, std::vector<char>& buffer) { Loading
adb/transport.cpp +8 −2 Original line number Diff line number Diff line Loading @@ -71,6 +71,7 @@ const char* const kFeaturePushSync = "push_sync"; const char* const kFeatureApex = "apex"; const char* const kFeatureFixedPushMkdir = "fixed_push_mkdir"; const char* const kFeatureAbb = "abb"; const char* const kFeatureFixedPushSymlinkTimestamp = "fixed_push_symlink_timestamp"; namespace { Loading Loading @@ -1005,8 +1006,13 @@ size_t atransport::get_max_payload() const { const FeatureSet& supported_features() { // Local static allocation to avoid global non-POD variables. static const FeatureSet* features = new FeatureSet{ kFeatureShell2, kFeatureCmd, kFeatureStat2, kFeatureFixedPushMkdir, kFeatureApex, kFeatureAbb, kFeatureShell2, kFeatureCmd, kFeatureStat2, kFeatureFixedPushMkdir, kFeatureApex, kFeatureAbb, kFeatureFixedPushSymlinkTimestamp, // Increment ADB_SERVER_VERSION when adding a feature that adbd needs // to know about. Otherwise, the client can be stuck running an old // version of the server even after upgrading their copy of adb. Loading
adb/transport.h +2 −0 Original line number Diff line number Diff line Loading @@ -67,6 +67,8 @@ extern const char* const kFeatureApex; extern const char* const kFeatureFixedPushMkdir; // adbd supports android binder bridge (abb). extern const char* const kFeatureAbb; // adbd properly updates symlink timestamps on push. extern const char* const kFeatureFixedPushSymlinkTimestamp; TransportId NextTransportId(); Loading