From d4de636cdf86cec202b4d365c55814fe8ea3be34 Mon Sep 17 00:00:00 2001 From: Zim Date: Thu, 12 Dec 2019 16:22:27 +0000 Subject: Use lower filesystem path when destroying user data with FUSE With the FUSE prop enabled, when a user is removed, the upper filesystem path would have been unmounted before installd gets to delete its content and an empty tmpfs will be deleted instead, leaving the content on the lower filesystem. Now, we always use the lower filesystem when deleting the users dir and cache. This is fine on devices without sdcardfs but on devices running sdcardfs, we should use the sdcardfs path instead to avoid VFS inode cache inconsistencies Test: adb shell pm create-user && adb shell am start-user 10 && adb shell pm delete-user. Verify that /data/media/10 is deleted Bug: 135341433 Change-Id: Iaeb9ea3db373d358251644a95b3390cfa2b8f24a --- cmds/installd/InstalldNativeService.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'cmds/installd/InstalldNativeService.cpp') diff --git a/cmds/installd/InstalldNativeService.cpp b/cmds/installd/InstalldNativeService.cpp index b23d69c52f..a6e4e4efb6 100644 --- a/cmds/installd/InstalldNativeService.cpp +++ b/cmds/installd/InstalldNativeService.cpp @@ -2799,6 +2799,8 @@ binder::Status InstalldNativeService::invalidateMounts() { std::getline(in, ignored); if (android::base::GetBoolProperty(kFuseProp, false)) { + // TODO(b/146139106): Use sdcardfs mounts on devices running sdcardfs so we don't bypass + // it's VFS cache if (target.compare(0, 17, "/mnt/pass_through") == 0) { LOG(DEBUG) << "Found storage mount " << source << " at " << target; mStorageMounts[source] = target; @@ -2820,6 +2822,17 @@ std::string InstalldNativeService::findDataMediaPath( std::lock_guard lock(mMountsLock); const char* uuid_ = uuid ? uuid->c_str() : nullptr; auto path = StringPrintf("%s/media", create_data_path(uuid_).c_str()); + if (android::base::GetBoolProperty(kFuseProp, false)) { + // TODO(b/146139106): This is only safe on devices not running sdcardfs where there is no + // risk of bypassing the sdcardfs VFS cache + + // Always use the lower filesystem path on FUSE enabled devices not running sdcardfs + // The upper filesystem path, /mnt/pass_through/// which was a bind mount + // to the lower filesytem may have been unmounted already when a user is + // removed and the path will now be pointing to a tmpfs without content + return StringPrintf("%s/%u", path.c_str(), userid); + } + auto resolved = mStorageMounts[path]; if (resolved.empty()) { LOG(WARNING) << "Failed to find storage mount for " << path; -- cgit v1.2.3-59-g8ed1b