OSDN Git Service

Unmount public volume if FUSE mount fails
authorZim <zezeozue@google.com>
Wed, 17 Jun 2020 13:56:10 +0000 (14:56 +0100)
committerZim <zezeozue@google.com>
Mon, 22 Jun 2020 13:26:57 +0000 (14:26 +0100)
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

model/PublicVolume.cpp

index 64b5dfa..9ca782b 100644 (file)
@@ -238,6 +238,7 @@ status_t PublicVolume::doMount() {
 
         if (result != 0) {
             LOG(ERROR) << "Failed to mount public fuse volume";
+            doUnmount();
             return -result;
         }
 
@@ -247,6 +248,8 @@ status_t PublicVolume::doMount() {
             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;
             }
         }