Merge "Add supportsCheckpoint"

This commit is contained in:
Treehugger Robot 2019-01-24 06:14:44 +00:00 committed by Gerrit Code Review
commit 9b2b8fd459
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 } // 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) { 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

@ -23,6 +23,8 @@
namespace android { namespace android {
namespace vold { namespace vold {
android::binder::Status cp_supportsCheckpoint(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

@ -864,5 +864,12 @@ binder::Status VoldNativeService::abortChanges() {
return cp_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 vold
} // namespace android } // namespace android

View file

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

View file

@ -104,6 +104,7 @@ interface IVold {
void prepareCheckpoint(); void prepareCheckpoint();
void restoreCheckpoint(@utf8InCpp String device); void restoreCheckpoint(@utf8InCpp String device);
void markBootAttempt(); void markBootAttempt();
boolean supportsCheckpoint();
@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

@ -105,6 +105,10 @@ int main(int argc, char** argv) {
checkStatus(vold->mountFstab(args[2])); checkStatus(vold->mountFstab(args[2]));
} else if (args[0] == "cryptfs" && args[1] == "encryptFstab" && args.size() == 3) { } else if (args[0] == "cryptfs" && args[1] == "encryptFstab" && args.size() == 3) {
checkStatus(vold->encryptFstab(args[2])); 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) { } 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);