summaryrefslogtreecommitdiff
path: root/Utils.cpp
diff options
context:
space:
mode:
authorPaul Crowley <paulcrowley@google.com>2018-12-07 06:35:48 +0000
committerGerrit Code Review <noreply-gerritcodereview@google.com>2018-12-07 06:35:48 +0000
commit53b0d95903e65c31df74480cd1f11703ce63f092 (patch)
treebecde3ba69145754e12048fa59eba7268af940cf /Utils.cpp
parenta33b765ca09da69c9bab418f751770586e69ac24 (diff)
parent4df104f335db57c0ee82d310689e6faf9cf7c2d0 (diff)
Merge "Do lazy-unmount to /storage directly"
Diffstat (limited to 'Utils.cpp')
-rw-r--r--Utils.cpp23
1 files changed, 2 insertions, 21 deletions
diff --git a/Utils.cpp b/Utils.cpp
index f72edbe..3bbdf3a 100644
--- a/Utils.cpp
+++ b/Utils.cpp
@@ -751,29 +751,10 @@ bool IsRunningInEmulator() {
}
status_t UnmountTree(const std::string& prefix) {
- FILE* fp = setmntent("/proc/mounts", "re");
- if (fp == NULL) {
- PLOG(ERROR) << "Failed to open /proc/mounts";
+ if (umount2(prefix.c_str(), MNT_DETACH)) {
+ PLOG(ERROR) << "Failed to unmount " << prefix;
return -errno;
}
-
- // Some volumes can be stacked on each other, so force unmount in
- // reverse order to give us the best chance of success.
- std::list<std::string> toUnmount;
- mntent* mentry;
- while ((mentry = getmntent(fp)) != NULL) {
- auto test = std::string(mentry->mnt_dir) + "/";
- if (android::base::StartsWith(test, prefix)) {
- toUnmount.push_front(test);
- }
- }
- endmntent(fp);
-
- for (const auto& path : toUnmount) {
- if (umount2(path.c_str(), MNT_DETACH)) {
- PLOG(ERROR) << "Failed to unmount " << path;
- }
- }
return OK;
}