Add vdc checkpoint supportsBlockCheckpoint

Also add vdc checkpoint supportsFileCheckpoint
This is to allow tests to be specific to supported checkpoint mode.

Test: Built on Taimen and Crosshatch, made sure both new functions work
as expected

Change-Id: I0eab7453b13c0a2e31840ef9ad24a692cec55b00
This commit is contained in:
Paul Lawrence 2019-03-18 13:36:40 -07:00
parent 7573874d3f
commit c5c79c5679
6 changed files with 54 additions and 0 deletions

View file

@ -84,6 +84,30 @@ Status cp_supportsCheckpoint(bool& result) {
return Status::ok(); return Status::ok();
} }
Status cp_supportsBlockCheckpoint(bool& result) {
result = false;
for (const auto& entry : fstab_default) {
if (entry.fs_mgr_flags.checkpoint_blk) {
result = true;
return Status::ok();
}
}
return Status::ok();
}
Status cp_supportsFileCheckpoint(bool& result) {
result = false;
for (const auto& entry : fstab_default) {
if (entry.fs_mgr_flags.checkpoint_fs) {
result = true;
return Status::ok();
}
}
return Status::ok();
}
Status cp_startCheckpoint(int retry) { Status cp_startCheckpoint(int retry) {
if (retry < -1) return Status::fromExceptionCode(EINVAL, "Retry count must be more than -1"); if (retry < -1) return Status::fromExceptionCode(EINVAL, "Retry count must be more than -1");
std::string content = std::to_string(retry + 1); std::string content = std::to_string(retry + 1);

View file

@ -25,6 +25,10 @@ namespace vold {
android::binder::Status cp_supportsCheckpoint(bool& result); android::binder::Status cp_supportsCheckpoint(bool& result);
android::binder::Status cp_supportsBlockCheckpoint(bool& result);
android::binder::Status cp_supportsFileCheckpoint(bool& result);
android::binder::Status cp_startCheckpoint(int retry); android::binder::Status cp_startCheckpoint(int retry);
android::binder::Status cp_commitChanges(); android::binder::Status cp_commitChanges();

View file

@ -879,5 +879,19 @@ binder::Status VoldNativeService::supportsCheckpoint(bool* _aidl_return) {
return cp_supportsCheckpoint(*_aidl_return); return cp_supportsCheckpoint(*_aidl_return);
} }
binder::Status VoldNativeService::supportsBlockCheckpoint(bool* _aidl_return) {
ENFORCE_UID(AID_SYSTEM);
ACQUIRE_LOCK;
return cp_supportsBlockCheckpoint(*_aidl_return);
}
binder::Status VoldNativeService::supportsFileCheckpoint(bool* _aidl_return) {
ENFORCE_UID(AID_SYSTEM);
ACQUIRE_LOCK;
return cp_supportsFileCheckpoint(*_aidl_return);
}
} // namespace vold } // namespace vold
} // namespace android } // namespace android

View file

@ -131,6 +131,8 @@ class VoldNativeService : public BinderService<VoldNativeService>, public os::Bn
binder::Status markBootAttempt(); binder::Status markBootAttempt();
binder::Status abortChanges(); binder::Status abortChanges();
binder::Status supportsCheckpoint(bool* _aidl_return); binder::Status supportsCheckpoint(bool* _aidl_return);
binder::Status supportsBlockCheckpoint(bool* _aidl_return);
binder::Status supportsFileCheckpoint(bool* _aidl_return);
}; };
} // namespace vold } // namespace vold

View file

@ -106,6 +106,8 @@ interface IVold {
void restoreCheckpointPart(@utf8InCpp String device, int count); void restoreCheckpointPart(@utf8InCpp String device, int count);
void markBootAttempt(); void markBootAttempt();
boolean supportsCheckpoint(); boolean supportsCheckpoint();
boolean supportsBlockCheckpoint();
boolean supportsFileCheckpoint();
@utf8InCpp String createStubVolume(@utf8InCpp String sourcePath, @utf8InCpp String createStubVolume(@utf8InCpp String sourcePath,
@utf8InCpp String mountPath, @utf8InCpp String fsType, @utf8InCpp String mountPath, @utf8InCpp String fsType,

View file

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