diff options
author | David Anderson <dvander@google.com> | 2018-10-25 12:51:25 -0700 |
---|---|---|
committer | David Anderson <dvander@google.com> | 2018-10-25 20:10:20 +0000 |
commit | 629e51c1091b751b4fecbe1a7811208d9436b16c (patch) | |
tree | e2b1784a8a31a71db09514ec8ba666b3248e1d6e /fastboot | |
parent | 0444a8cbd96c3dbb75399886b13ece5dc3d6ffa9 (diff) | |
download | system_core-629e51c1091b751b4fecbe1a7811208d9436b16c.tar.gz system_core-629e51c1091b751b4fecbe1a7811208d9436b16c.tar.bz2 system_core-629e51c1091b751b4fecbe1a7811208d9436b16c.zip |
fastboot: Resize logical partitions when using the flash command.
If an image size changes slightly in between "flashall" and some change
in the build, it's inconvenient to have to reflash the whole device again.
This patch resizes partitions when using a normal flash command, to
improve the developer workflow.
Bug: N/A
Test: fastboot flash system
Change-Id: I349364a4742a0c15748f545fcfda946107720d45
Diffstat (limited to 'fastboot')
-rw-r--r-- | fastboot/fastboot.cpp | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/fastboot/fastboot.cpp b/fastboot/fastboot.cpp index f9dd6b5e1..3e97716d1 100644 --- a/fastboot/fastboot.cpp +++ b/fastboot/fastboot.cpp @@ -1096,12 +1096,20 @@ static void do_for_partitions(const std::string& part, const std::string& slot, } } +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); } @@ -1144,11 +1152,6 @@ static bool if_partition_exists(const std::string& partition, const std::string& 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"); |