From 2ffc31b090dc2af7d833a4eea9e31337e3308648 Mon Sep 17 00:00:00 2001 From: David Anderson Date: Mon, 23 Mar 2020 23:43:45 -0700 Subject: [PATCH] fastbootd: Unmount /cache before flashing. Bug: 150112538 Test: fastboot flash cache on non-A/B device Change-Id: I8a86bc4d12e4b3be020bbe47e02262a5aaa913a7 --- fastboot/device/commands.cpp | 1 + fastboot/device/fastboot_device.cpp | 15 +++++++++++++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/fastboot/device/commands.cpp b/fastboot/device/commands.cpp index ca120c62a..b8eee4ac1 100644 --- a/fastboot/device/commands.cpp +++ b/fastboot/device/commands.cpp @@ -31,6 +31,7 @@ #include #include #include +#include #include #include #include diff --git a/fastboot/device/fastboot_device.cpp b/fastboot/device/fastboot_device.cpp index 31fc35937..bb085c536 100644 --- a/fastboot/device/fastboot_device.cpp +++ b/fastboot/device/fastboot_device.cpp @@ -16,18 +16,22 @@ #include "fastboot_device.h" +#include + #include #include #include #include +#include +#include #include -#include - #include "constants.h" #include "flashing.h" #include "usb_client.h" +using android::fs_mgr::EnsurePathUnmounted; +using android::fs_mgr::Fstab; using ::android::hardware::hidl_string; using ::android::hardware::boot::V1_0::IBootControl; using ::android::hardware::boot::V1_0::Slot; @@ -64,6 +68,13 @@ FastbootDevice::FastbootDevice() if (boot_control_hal_) { boot1_1_ = android::hardware::boot::V1_1::IBootControl::castFrom(boot_control_hal_); } + + // Make sure cache is unmounted, since recovery will have mounted it for + // logging. + Fstab fstab; + if (ReadDefaultFstab(&fstab)) { + EnsurePathUnmounted(&fstab, "/cache"); + } } FastbootDevice::~FastbootDevice() {