Clear bind mounts for public volumes when clone profile stops
Currently, if clone profile gets removed, we don't clear public volume
bind mounts for this profile. This would make subsequent unmounting and
then mounting the public volume again not possible as unmounting the
public volume after stopping clone profile wouldn't be able to clean up
clone profile bind mounts.
This fix tries to clean up clone profile find mounts for public volumes
as soon as the clone profile gets stopped or removed. Hence, subsequent
unmounting and mounting for the volume would succeed normally.
Test: Manual
Bug: 318335297
Bug: 369519866
Flag: EXEMPT bug fix
Change-Id: I32e14e520d742f4294820c1d9d92c2997a36d91a
diff --git a/model/PublicVolume.cpp b/model/PublicVolume.cpp
index 91b1ca2..747598a 100644
--- a/model/PublicVolume.cpp
+++ b/model/PublicVolume.cpp
@@ -88,6 +88,15 @@
return OK;
}
+std::string PublicVolume::getStableName() {
+ // Use UUID as stable name, if available
+ std::string stableName = getId();
+ if (!mFsUuid.empty()) {
+ stableName = mFsUuid;
+ }
+ return stableName;
+}
+
status_t PublicVolume::doCreate() {
return CreateDeviceNode(mDevPath, mDevice);
}
@@ -115,11 +124,7 @@
return -EIO;
}
- // Use UUID as stable name, if available
- std::string stableName = getId();
- if (!mFsUuid.empty()) {
- stableName = mFsUuid;
- }
+ std::string stableName = getStableName();
mRawPath = StringPrintf("/mnt/media_rw/%s", stableName.c_str());
@@ -286,10 +291,7 @@
status_t PublicVolume::bindMountForUser(userid_t user_id) {
userid_t mountUserId = getMountUserId();
- std::string stableName = getId();
- if (!mFsUuid.empty()) {
- stableName = mFsUuid;
- }
+ std::string stableName = getStableName();
LOG(INFO) << "Bind Mounting Public Volume for user: " << user_id
<< ".Mount owner: " << mountUserId;
@@ -310,11 +312,7 @@
KillProcessesUsingPath(getPath());
if (mFuseMounted) {
- // Use UUID as stable name, if available
- std::string stableName = getId();
- if (!mFsUuid.empty()) {
- stableName = mFsUuid;
- }
+ std::string stableName = getStableName();
// Unmount bind mounts for running users
auto vol_manager = VolumeManager::Instance();