Merge "init/reboot: call MNT_FORCE at the last umount(2)" am: 4e008547be

am: eacc9cd637

Change-Id: Idbf7d95dcda2c50c914e7fbf6b180ecc14c57987
This commit is contained in:
Jaegeuk Kim 2017-10-05 20:40:54 +00:00 committed by android-build-merger
commit 647a720ee1

View file

@ -86,8 +86,8 @@ class MountEntry {
mnt_type_(entry.mnt_type), mnt_type_(entry.mnt_type),
mnt_opts_(entry.mnt_opts) {} mnt_opts_(entry.mnt_opts) {}
bool Umount() { bool Umount(bool force) {
int r = umount2(mnt_dir_.c_str(), 0); int r = umount2(mnt_dir_.c_str(), force ? MNT_FORCE : 0);
if (r == 0) { if (r == 0) {
LOG(INFO) << "umounted " << mnt_fsname_ << ":" << mnt_dir_ << " opts " << mnt_opts_; LOG(INFO) << "umounted " << mnt_fsname_ << ":" << mnt_dir_ << " opts " << mnt_opts_;
return true; return true;
@ -280,14 +280,15 @@ static UmountStat UmountPartitions(std::chrono::milliseconds timeout) {
bool unmount_done = true; bool unmount_done = true;
if (emulated_devices.size() > 0) { if (emulated_devices.size() > 0) {
unmount_done = std::all_of(emulated_devices.begin(), emulated_devices.end(), unmount_done = std::all_of(emulated_devices.begin(), emulated_devices.end(),
[](auto& entry) { return entry.Umount(); }); [](auto& entry) { return entry.Umount(false); });
if (unmount_done) { if (unmount_done) {
sync(); sync();
} }
} }
unmount_done = std::all_of(block_devices.begin(), block_devices.end(), unmount_done =
[](auto& entry) { return entry.Umount(); }) && std::all_of(block_devices.begin(), block_devices.end(),
unmount_done; [&timeout](auto& entry) { return entry.Umount(timeout == 0ms); }) &&
unmount_done;
if (unmount_done) { if (unmount_done) {
return UMOUNT_STAT_SUCCESS; return UMOUNT_STAT_SUCCESS;
} }