From 4b86df14265521ff737589d91375670e85d74b4a Mon Sep 17 00:00:00 2001 From: Daniel Rosenberg Date: Thu, 8 Nov 2018 22:18:37 -0800 Subject: [PATCH] Fix error reporting in cp_commitChanges Only trys to commit if necessary, and reports errors if commiting fails. RemoveFileIfExists returns true on success. Test: vdc checkpoint startCheckpoint, reboot, and then vdc checkpoint commitChanges Bug: 111020314 Change-Id: Ie1b3e49beb3ca04f2881fcc595882c607368b477 --- Checkpoint.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/Checkpoint.cpp b/Checkpoint.cpp index 94a78eb..e238acf 100644 --- a/Checkpoint.cpp +++ b/Checkpoint.cpp @@ -82,6 +82,7 @@ Status cp_startCheckpoint(int retry) { } Status cp_commitChanges() { + if (!cp_needsCheckpoint()) return Status::ok(); // Must take action for list of mounted checkpointed things here // To do this, we walk the list of mounted file systems. // But we also need to get the matching fstab entries to see @@ -104,14 +105,17 @@ Status cp_commitChanges() { if (fs_mgr_is_checkpoint_fs(fstab_rec)) { if (!strcmp(fstab_rec->fs_type, "f2fs")) { - mount(mount_rec->blk_device, mount_rec->mount_point, "none", - MS_REMOUNT | fstab_rec->flags, "checkpoint=enable"); + if (mount(mount_rec->blk_device, mount_rec->mount_point, "none", + MS_REMOUNT | fstab_rec->flags, "checkpoint=enable")) { + return Status::fromExceptionCode(EINVAL, "Failed to remount"); + } } } else if (fs_mgr_is_checkpoint_blk(fstab_rec)) { - setBowState(mount_rec->blk_device, "2"); + if (!setBowState(mount_rec->blk_device, "2")) + return Status::fromExceptionCode(EINVAL, "Failed to set bow state"); } } - if (android::base::RemoveFileIfExists(kMetadataCPFile, &err_str)) + if (!android::base::RemoveFileIfExists(kMetadataCPFile, &err_str)) return Status::fromExceptionCode(errno, err_str.c_str()); return Status::ok(); }