Merge "remount: Check device mapper to see if verity is already disabled"

This commit is contained in:
Yi-yo Chiang 2022-11-18 03:11:57 +00:00 committed by Gerrit Code Review
commit a6844e4c62

View file

@ -386,16 +386,15 @@ bool RemountPartition(Fstab& fstab, Fstab& mounts, FstabEntry& entry) {
} }
// Now remount! // Now remount!
if (::mount(blk_device.c_str(), mount_point.c_str(), entry.fs_type.c_str(), MS_REMOUNT, for (const auto& mnt_point : {mount_point, entry.mount_point}) {
nullptr) == 0) { if (::mount(blk_device.c_str(), mnt_point.c_str(), entry.fs_type.c_str(), MS_REMOUNT,
return true;
}
if ((errno == EINVAL) && (mount_point != entry.mount_point)) {
mount_point = entry.mount_point;
if (::mount(blk_device.c_str(), mount_point.c_str(), entry.fs_type.c_str(), MS_REMOUNT,
nullptr) == 0) { nullptr) == 0) {
LOG(INFO) << "Remounted " << mnt_point << " as RW";
return true; return true;
} }
if (errno != EINVAL || mount_point == entry.mount_point) {
break;
}
} }
PLOG(ERROR) << "failed to remount partition dev:" << blk_device << " mnt:" << mount_point; PLOG(ERROR) << "failed to remount partition dev:" << blk_device << " mnt:" << mount_point;
@ -484,8 +483,16 @@ bool do_remount(Fstab& fstab, const std::vector<std::string>& partition_args,
return false; return false;
} }
if (verity_result.want_reboot) { if (verity_result.want_reboot) {
check_result->reboot_later = true; // TODO(b/259207493): emulator has incorrect androidboot.veritymode value, causing
check_result->disabled_verity = true; // .want_reboot to always be true. In order to workaround this, double check device mapper
// to see if verity is already disabled.
for (const auto& partition : partitions) {
if (fs_mgr_is_verity_enabled(partition)) {
check_result->reboot_later = true;
check_result->disabled_verity = true;
break;
}
}
} }
// Optionally setup overlayfs backing. // Optionally setup overlayfs backing.
@ -660,10 +667,10 @@ int main(int argc, char* argv[]) {
} else if (check_result.setup_overlayfs) { } else if (check_result.setup_overlayfs) {
LOG(INFO) << "Overlayfs enabled."; LOG(INFO) << "Overlayfs enabled.";
} }
if (remount_success) { if (remount_success && check_result.remounted_anything) {
LOG(INFO) << "remount succeeded"; LOG(INFO) << "Remount succeeded";
} else { } else if (!remount_success) {
LOG(ERROR) << "remount failed"; LOG(ERROR) << "Remount failed";
} }
if (check_result.reboot_later) { if (check_result.reboot_later) {
if (auto_reboot) { if (auto_reboot) {