From 08deaa39d24c18617812570356fed38f7495048a Mon Sep 17 00:00:00 2001 From: Howard Chen Date: Mon, 11 Jan 2021 11:46:50 +0800 Subject: [PATCH] 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 --- fs_mgr/libfiemap/image_manager.cpp | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/fs_mgr/libfiemap/image_manager.cpp b/fs_mgr/libfiemap/image_manager.cpp index 93fc1316f..841f21564 100644 --- a/fs_mgr/libfiemap/image_manager.cpp +++ b/fs_mgr/libfiemap/image_manager.cpp @@ -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();