am f6852593: am cb42a40a: Merge "Clean up any/all stale partition tables." into mnc-dr-dev
* commit 'f68525931e1b9ab6938d87bb95a2fa7966f046c4':
Clean up any/all stale partition tables.
diff --git a/Disk.cpp b/Disk.cpp
index 1e76bee..d5f3e5d 100644
--- a/Disk.cpp
+++ b/Disk.cpp
@@ -340,10 +340,24 @@
}
status_t Disk::partitionPublic() {
+ int res;
+
// TODO: improve this code
destroyAllVolumes();
mJustPartitioned = true;
+ // First nuke any existing partition table
+ std::vector<std::string> cmd;
+ cmd.push_back(kSgdiskPath);
+ cmd.push_back("--zap-all");
+ cmd.push_back(mDevPath);
+
+ // Zap sometimes returns an error when it actually succeeded, so
+ // just log as warning and keep rolling forward.
+ if ((res = ForkExecvp(cmd)) != 0) {
+ LOG(WARNING) << "Failed to zap; status " << res;
+ }
+
struct disk_info dinfo;
memset(&dinfo, 0, sizeof(dinfo));