AppFuseUtil: Call ForceUnmount before PrepareDir.

We'd previously call ForceUnmount after the call to PrepareDir,
which would sometimes fail because the userspace counterpart of a
FUSE FS that was previously mounted at that mountpoint has gone
away. This is usually reproducible after a runtime restart.

Bug: 128459728
Test: Loop (adb shell start; atest MediaStore_Images_MediaTest; adb shell stop;)
Change-Id: I38d3908487123614c338266f983afb04e3ed78d4
This commit is contained in:
Narayan Kamath 2019-04-09 18:45:32 +01:00
parent 143498f797
commit 15ad33a8b1

View file

@ -49,9 +49,6 @@ static android::status_t GetMountPath(uid_t uid, const std::string& name, std::s
} }
static android::status_t Mount(int device_fd, const std::string& path) { static android::status_t Mount(int device_fd, const std::string& path) {
// Remove existing mount.
android::vold::ForceUnmount(path);
const auto opts = StringPrintf( const auto opts = StringPrintf(
"fd=%i," "fd=%i,"
"rootmode=40000," "rootmode=40000,"
@ -115,6 +112,11 @@ int MountAppFuse(uid_t uid, int mountId, android::base::unique_fd* device_fd) {
return -1; return -1;
} }
// Forcibly remove the existing mount before we attempt to prepare the
// directory. If we have a dangling mount, then PrepareDir may fail if the
// indirection to FUSE doesn't work.
android::vold::ForceUnmount(path);
// Create directories. // Create directories.
const android::status_t result = android::vold::PrepareDir(path, 0700, 0, 0); const android::status_t result = android::vold::PrepareDir(path, 0700, 0, 0);
if (result != android::OK) { if (result != android::OK) {