Merge "Do lazy-unmount to /storage directly" am: 53b0d95903 am: fbc24b5c8f

am: 0bafc3b2c5

Change-Id: Icffe008b85b59357a743cd19f28fe5bb97722895
gugelfrei
Paul Crowley 6 years ago committed by android-build-merger
commit c2fc472c7c

@ -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;
}

Loading…
Cancel
Save