diff options
| author | Daniel Rosenberg <drosen@google.com> | 2019-01-22 17:27:25 -0800 |
|---|---|---|
| committer | Daniel Rosenberg <drosen@google.com> | 2019-01-22 17:58:03 -0800 |
| commit | 9b667fbe416363ff0cb7aeb58e67c9da5ad61a37 (patch) | |
| tree | 3450e317bfff82aede583c604f0565d43e482c7d /Checkpoint.cpp | |
| parent | f156c40404b64d49716777c937572044bb2ac26f (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.cpp | 15 |
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); |
