Clean up ASEC unmounting on physical storage.
When physical devices are unsafely removed, unmountAllAsecsInDir()
fails to find any ASECs, and leaves them all mounted, preventing the
rest of volume from going down.
Now we examine all ASEC containers, and remove when on external
storage, or when the storage media is no longer found.
Bug: 11175082
Change-Id: Iffa38ea43f7e5ad78b598374ebeb60a8727d99fd
diff --git a/DirectVolume.cpp b/DirectVolume.cpp
index 4e0d621..960eef6 100644
--- a/DirectVolume.cpp
+++ b/DirectVolume.cpp
@@ -321,15 +321,16 @@
* Yikes, our mounted partition is going away!
*/
+ bool providesAsec = (getFlags() & VOL_PROVIDES_ASEC) != 0;
+ if (providesAsec && mVm->cleanupAsec(this, true)) {
+ SLOGE("Failed to cleanup ASEC - unmount will probably fail!");
+ }
+
snprintf(msg, sizeof(msg), "Volume %s %s bad removal (%d:%d)",
getLabel(), getFuseMountpoint(), major, minor);
mVm->getBroadcaster()->sendBroadcast(ResponseCode::VolumeBadRemoval,
msg, false);
- if (mVm->cleanupAsec(this, true)) {
- SLOGE("Failed to cleanup ASEC - unmount will probably fail!");
- }
-
if (Volume::unmountVol(true, false)) {
SLOGE("Failed to unmount volume on bad removal (%s)",
strerror(errno));