Merge "Fix error reporting in cp_commitChanges" am: 2a683d4ce6 am: b0b31d360d
am: bc03daec62

Change-Id: I5f223c94f436e33c74272f0364e11697f3b7838e
diff --git a/Checkpoint.cpp b/Checkpoint.cpp
index 94a78eb..e238acf 100644
--- a/Checkpoint.cpp
+++ b/Checkpoint.cpp
@@ -82,6 +82,7 @@
 }
 
 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 @@
 
         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();
 }