Add supportsCheckpoint
This returns true if any entries in the fstab have checkpoint=
set.
Test: Call vdc checkpoint supportsCheckpoint. Should return 1
iff an fstab entry has checkpoint=fs or checkpoint=block set
Bug: 111020314
Change-Id: Ic79bc96ded4da6605f73992dcff542e7cb50d705
diff --git a/Checkpoint.cpp b/Checkpoint.cpp
index 7586a6c..e06e855 100644
--- a/Checkpoint.cpp
+++ b/Checkpoint.cpp
@@ -67,6 +67,21 @@
} // namespace
+Status cp_supportsCheckpoint(bool& result) {
+ result = false;
+ auto fstab_default = std::unique_ptr<fstab, decltype(&fs_mgr_free_fstab)>{
+ fs_mgr_read_fstab_default(), fs_mgr_free_fstab};
+ if (!fstab_default) return Status::fromExceptionCode(EINVAL, "Failed to get fstab");
+
+ for (int i = 0; i < fstab_default->num_entries; ++i) {
+ if (fs_mgr_is_checkpoint(&fstab_default->recs[i])) {
+ result = true;
+ return Status::ok();
+ }
+ }
+ return Status::ok();
+}
+
Status cp_startCheckpoint(int retry) {
if (retry < -1) return Status::fromExceptionCode(EINVAL, "Retry count must be more than -1");
std::string content = std::to_string(retry + 1);