Merge "Abort migration early when not enough space." into oc-dev

gugelfrei
TreeHugger Robot 7 years ago committed by Android (Google) Code Review
commit e6c142174c

@ -128,6 +128,12 @@ static status_t execCp(const std::string& fromPath, const std::string& toPath,
uint64_t expectedBytes = GetTreeBytes(fromPath);
uint64_t startFreeBytes = GetFreeBytes(toPath);
if (expectedBytes > startFreeBytes) {
LOG(ERROR) << "Data size " << expectedBytes << " is too large to fit in free space "
<< startFreeBytes;
return -1;
}
std::vector<std::string> cmd;
cmd.push_back(kCpPath);
cmd.push_back("-p"); /* preserve timestamps, ownership, and permissions */

@ -432,7 +432,7 @@ status_t NormalizeHex(const std::string& in, std::string& out) {
uint64_t GetFreeBytes(const std::string& path) {
struct statvfs sb;
if (statvfs(path.c_str(), &sb) == 0) {
return (uint64_t)sb.f_bfree * sb.f_bsize;
return (uint64_t) sb.f_bavail * sb.f_frsize;
} else {
return -1;
}

Loading…
Cancel
Save