Fix the MapWithLoopDevice

This fix is to keep the dm line in the status file and let the
UnmapImageDevice to clean up correctly.

Bug: 171861574
Test: execute following command on a device with a SD card inserted
    adb shell am start-activity \
        -n com.android.dynsystem/com.android.dynsystem.VerificationActivity \
        -a android.os.image.action.START_INSTALL \
        -d file:///storage/emulated/0/Download/system.raw.gz \
        --el KEY_SYSTEM_SIZE $(du -b system.raw|cut -f1) \
        --el KEY_USERDATA_SIZE 4294967296

Change-Id: Ia56f8f724f04e7e20586e088c89b62a1068766e4
This commit is contained in:
Howard Chen 2021-01-11 11:46:50 +08:00
parent bdd1244d54
commit 08deaa39d2
1 changed files with 7 additions and 8 deletions

View File

@ -486,15 +486,14 @@ bool ImageManager::MapWithLoopDevice(const std::string& name,
if (!MapWithLoopDeviceList(loop_devices, name, timeout_ms, path)) {
return false;
}
} else {
auto status_message = "loop:" + loop_devices.back();
auto status_file = GetStatusFilePath(name);
if (!android::base::WriteStringToFile(status_message, status_file)) {
PLOG(ERROR) << "Write failed: " << status_file;
return false;
}
}
auto status_message = "loop:" + loop_devices.back();
auto status_file = GetStatusFilePath(name);
if (!android::base::WriteStringToFile(status_message, status_file)) {
PLOG(ERROR) << "Write failed: " << status_file;
return false;
}
auto_detach.Commit();
*path = loop_devices.back();