Merge "Add supportsCheckpoint" am: 9b2b8fd459 am: 908a4569e9

am: 4cd2102637

Change-Id: I73fea54d60f27468a46bca872ae2f21bdfcb67a1
This commit is contained in:
Daniel Rosenberg 2019-01-23 22:43:28 -08:00 committed by android-build-merger
commit 38a2899523
6 changed files with 30 additions and 0 deletions

View file

@ -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);

View file

@ -23,6 +23,8 @@
namespace android {
namespace vold {
android::binder::Status cp_supportsCheckpoint(bool& result);
android::binder::Status cp_startCheckpoint(int retry);
android::binder::Status cp_commitChanges();

View file

@ -996,5 +996,12 @@ binder::Status VoldNativeService::abortChanges() {
return cp_abortChanges();
}
binder::Status VoldNativeService::supportsCheckpoint(bool* _aidl_return) {
ENFORCE_UID(AID_SYSTEM);
ACQUIRE_LOCK;
return cp_supportsCheckpoint(*_aidl_return);
}
} // namespace vold
} // namespace android

View file

@ -138,6 +138,7 @@ class VoldNativeService : public BinderService<VoldNativeService>, public os::Bn
binder::Status restoreCheckpoint(const std::string& mountPoint);
binder::Status markBootAttempt();
binder::Status abortChanges();
binder::Status supportsCheckpoint(bool* _aidl_return);
};
} // namespace vold

View file

@ -113,6 +113,7 @@ interface IVold {
void prepareCheckpoint();
void restoreCheckpoint(@utf8InCpp String device);
void markBootAttempt();
boolean supportsCheckpoint();
@utf8InCpp String createStubVolume(@utf8InCpp String sourcePath,
@utf8InCpp String mountPath, @utf8InCpp String fsType,

View file

@ -105,6 +105,10 @@ int main(int argc, char** argv) {
checkStatus(vold->mountFstab(args[2]));
} else if (args[0] == "cryptfs" && args[1] == "encryptFstab" && args.size() == 3) {
checkStatus(vold->encryptFstab(args[2]));
} else if (args[0] == "checkpoint" && args[1] == "supportsCheckpoint" && args.size() == 2) {
bool supported = false;
checkStatus(vold->supportsCheckpoint(&supported));
return supported ? 1 : 0;
} else if (args[0] == "checkpoint" && args[1] == "startCheckpoint" && args.size() == 3) {
int retry;
if (!android::base::ParseInt(args[2], &retry)) exit(EINVAL);