Unmount public volume if FUSE mount fails
Sometimes, during early boot, a public volume may be created before
the user is unlocked and the mount may fail. This mount failure does
not revert the lower fs mounts (sdcardfs and vfat). Subsequent
mount attempts will then fail because we'd attempt to mount vfat on
already mounted /mnt/media_rw/<volname>
Bug: 158489548
Test: Resilient to an artificial sleep in
StorageManagerService#completeUnlockUser to
delay user unlock longer than public volume mount
Change-Id: I9a1574596434a2eb6b2553c0c9220c2118c7e4fd
diff --git a/model/PublicVolume.cpp b/model/PublicVolume.cpp
index 64b5dfa..9ca782b 100644
--- a/model/PublicVolume.cpp
+++ b/model/PublicVolume.cpp
@@ -238,6 +238,7 @@
if (result != 0) {
LOG(ERROR) << "Failed to mount public fuse volume";
+ doUnmount();
return -result;
}
@@ -247,6 +248,8 @@
bool is_ready = false;
callback->onVolumeChecking(std::move(fd), getPath(), getInternalPath(), &is_ready);
if (!is_ready) {
+ LOG(ERROR) << "Failed to complete public volume mount";
+ doUnmount();
return -EIO;
}
}