[vold] Add mount lazy if forcemount fail.
[Description]
When we plug out external device, and
vold didn’t finish unmount process properly
which will lead folder under /mnt/media_rw not removed.
This will cause mount fail
when we plug in same device again
due to operation not permitted when create the folder again.
Test:
1.AC on/off pass
2.issue not seen
Bug: 194163828
Change-Id: Ia7c6c23ca55ce71cd6c3d3fa15bed5bc5199acfd
diff --git a/model/PublicVolume.cpp b/model/PublicVolume.cpp
index bf54c95..b8bfece 100644
--- a/model/PublicVolume.cpp
+++ b/model/PublicVolume.cpp
@@ -300,8 +300,15 @@
mSdcardFsWrite.clear();
mSdcardFsFull.clear();
}
- ForceUnmount(mRawPath);
- rmdir(mRawPath.c_str());
+
+ if (ForceUnmount(mRawPath) != 0){
+ umount2(mRawPath.c_str(),MNT_DETACH);
+ PLOG(INFO) << "use umount lazy if force unmount fail";
+ }
+ if(rmdir(mRawPath.c_str()) != 0) {
+ PLOG(INFO) << "rmdir mRawPath=" << mRawPath << " fail";
+ KillProcessesUsingPath(getPath());
+ }
mRawPath.clear();
return OK;