summaryrefslogtreecommitdiff
path: root/Checkpoint.cpp
diff options
context:
space:
mode:
authorDaniel Rosenberg <drosen@google.com>2019-01-22 17:27:25 -0800
committerDaniel Rosenberg <drosen@google.com>2019-01-22 17:58:03 -0800
commit9b667fbe416363ff0cb7aeb58e67c9da5ad61a37 (patch)
tree3450e317bfff82aede583c604f0565d43e482c7d /Checkpoint.cpp
parentf156c40404b64d49716777c937572044bb2ac26f (diff)
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
Diffstat (limited to 'Checkpoint.cpp')
-rw-r--r--Checkpoint.cpp15
1 files changed, 15 insertions, 0 deletions
diff --git a/Checkpoint.cpp b/Checkpoint.cpp
index 7586a6c..e06e855 100644
--- a/Checkpoint.cpp
+++ b/Checkpoint.cpp
@@ -67,6 +67,21 @@ bool setBowState(std::string const& block_device, std::string const& state) {
} // 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);