Merge "fastboot: Resize logical partitions when using the flash command."
diff --git a/fastboot/fastboot.cpp b/fastboot/fastboot.cpp
index 81350fd..6e257c9 100644
--- a/fastboot/fastboot.cpp
+++ b/fastboot/fastboot.cpp
@@ -1092,12 +1092,20 @@
}
}
+static bool is_logical(const std::string& partition) {
+ std::string value;
+ return fb->GetVar("is-logical:" + partition, &value) == fastboot::SUCCESS && value == "yes";
+}
+
static void do_flash(const char* pname, const char* fname) {
struct fastboot_buffer buf;
if (!load_buf(fname, &buf)) {
die("cannot load '%s': %s", fname, strerror(errno));
}
+ if (is_logical(pname)) {
+ fb->ResizePartition(pname, std::to_string(buf.image_size));
+ }
flash_buf(pname, &buf);
}
@@ -1140,11 +1148,6 @@
return fb->GetVar("partition-size:" + partition_name, &partition_size) == fastboot::SUCCESS;
}
-static bool is_logical(const std::string& partition) {
- std::string value;
- return fb->GetVar("is-logical:" + partition, &value) == fastboot::SUCCESS && value == "yes";
-}
-
static void reboot_to_userspace_fastboot() {
fb->RebootTo("fastboot");