summaryrefslogtreecommitdiff
path: root/partition_tools
diff options
context:
space:
mode:
authorSteven Moreland <smoreland@google.com>2024-01-17 22:24:31 +0000
committerSteven Moreland <smoreland@google.com>2024-01-17 22:26:04 +0000
commit46cd9d1b58bfe6fba99064a90033887055d1c529 (patch)
tree1f8ad8a0176d6a2e506146b96c32ce29696441a9 /partition_tools
parentdc4b13f35cdb7d5a7262914d10e5009993e80190 (diff)
downloadextras-46cd9d1b58bfe6fba99064a90033887055d1c529.tar.gz
lpmake: unlink before writing
If Cuttlefish was starting using an image that was built earlier, the build used to write over this image. Now, we unlink the output first, so we don't break any existing programs which are using the outputs: Though, there are other reasons that CF may not work from multiple builds: > Requested resuming a previous session (the default behavior) but the base images have changed under the overlay, making the overlay incompatible. Wiping the overlay files. Anyway, you can see it works: Test: boot CF with a new image build with an existing version already running List of devices attached 0.0.0.0:6520 device 0.0.0.0:6521 device Bug: 179194264 Change-Id: Ie83c568915880e656c011eda474e2d42dfd1fa17
Diffstat (limited to 'partition_tools')
-rw-r--r--partition_tools/lpmake.cc4
1 files changed, 4 insertions, 0 deletions
diff --git a/partition_tools/lpmake.cc b/partition_tools/lpmake.cc
index 16dfec52..d7085222 100644
--- a/partition_tools/lpmake.cc
+++ b/partition_tools/lpmake.cc
@@ -489,6 +489,10 @@ int main(int argc, char* argv[]) {
}
}
+ // unlink before writing, in case it is being used by an emulator or other program,
+ // we don't want to break that program by changing the data it is accessing.
+ unlink(output_path.c_str());
+
std::unique_ptr<LpMetadata> metadata = builder->Export();
if (!images.empty() || force_full_image) {
if (block_devices.size() == 1) {