Merge "vold: unlink ext4 encryption keys rather than revoking them"
diff --git a/MoveTask.cpp b/MoveTask.cpp
index 38cca04..ea64a1c 100644
--- a/MoveTask.cpp
+++ b/MoveTask.cpp
@@ -128,6 +128,12 @@
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 */
diff --git a/Utils.cpp b/Utils.cpp
index 8bdae92..050a92b 100644
--- a/Utils.cpp
+++ b/Utils.cpp
@@ -432,7 +432,7 @@
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;
}