Add vdc checkpoint restoreCheckpointPart
Restores the first n entries of a checkpoint. Allows automated testing of interrupted restores. Test: vdc checkpoint restoreCheckpoint [device] [n] Change-Id: I47570e8eba0bc3c6549a04a33600df05d393990b
This commit is contained in:
parent
bc1901f8af
commit
dda598103d
6 changed files with 23 additions and 2 deletions
|
@ -371,9 +371,10 @@ std::vector<char> relocatedRead(int device_fd, Relocations const& relocations, b
|
|||
|
||||
} // namespace
|
||||
|
||||
Status cp_restoreCheckpoint(const std::string& blockDevice) {
|
||||
Status cp_restoreCheckpoint(const std::string& blockDevice, int restore_limit) {
|
||||
bool validating = true;
|
||||
std::string action = "Validating";
|
||||
int restore_count = 0;
|
||||
|
||||
for (;;) {
|
||||
Relocations relocations;
|
||||
|
@ -449,6 +450,12 @@ Status cp_restoreCheckpoint(const std::string& blockDevice) {
|
|||
} else {
|
||||
lseek64(device_fd, le->source * kSectorSize, SEEK_SET);
|
||||
write(device_fd, &buffer[0], le->size);
|
||||
restore_count++;
|
||||
if (restore_limit && restore_count >= restore_limit) {
|
||||
LOG(WARNING) << "Hit the test limit";
|
||||
status = Status::fromExceptionCode(EAGAIN, "Hit the test limit");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -37,7 +37,7 @@ bool cp_needsCheckpoint();
|
|||
|
||||
android::binder::Status cp_prepareCheckpoint();
|
||||
|
||||
android::binder::Status cp_restoreCheckpoint(const std::string& mountPoint);
|
||||
android::binder::Status cp_restoreCheckpoint(const std::string& mountPoint, int count = 0);
|
||||
|
||||
android::binder::Status cp_markBootAttempt();
|
||||
|
||||
|
|
|
@ -850,6 +850,14 @@ binder::Status VoldNativeService::restoreCheckpoint(const std::string& mountPoin
|
|||
return cp_restoreCheckpoint(mountPoint);
|
||||
}
|
||||
|
||||
binder::Status VoldNativeService::restoreCheckpointPart(const std::string& mountPoint, int count) {
|
||||
ENFORCE_UID(AID_SYSTEM);
|
||||
CHECK_ARGUMENT_PATH(mountPoint);
|
||||
ACQUIRE_LOCK;
|
||||
|
||||
return cp_restoreCheckpoint(mountPoint, count);
|
||||
}
|
||||
|
||||
binder::Status VoldNativeService::markBootAttempt() {
|
||||
ENFORCE_UID(AID_SYSTEM);
|
||||
ACQUIRE_LOCK;
|
||||
|
|
|
@ -127,6 +127,7 @@ class VoldNativeService : public BinderService<VoldNativeService>, public os::Bn
|
|||
binder::Status commitChanges();
|
||||
binder::Status prepareCheckpoint();
|
||||
binder::Status restoreCheckpoint(const std::string& mountPoint);
|
||||
binder::Status restoreCheckpointPart(const std::string& mountPoint, int count);
|
||||
binder::Status markBootAttempt();
|
||||
binder::Status abortChanges();
|
||||
binder::Status supportsCheckpoint(bool* _aidl_return);
|
||||
|
|
|
@ -103,6 +103,7 @@ interface IVold {
|
|||
void commitChanges();
|
||||
void prepareCheckpoint();
|
||||
void restoreCheckpoint(@utf8InCpp String device);
|
||||
void restoreCheckpointPart(@utf8InCpp String device, int count);
|
||||
void markBootAttempt();
|
||||
boolean supportsCheckpoint();
|
||||
|
||||
|
|
4
vdc.cpp
4
vdc.cpp
|
@ -127,6 +127,10 @@ int main(int argc, char** argv) {
|
|||
checkStatus(vold->prepareCheckpoint());
|
||||
} else if (args[0] == "checkpoint" && args[1] == "restoreCheckpoint" && args.size() == 3) {
|
||||
checkStatus(vold->restoreCheckpoint(args[2]));
|
||||
} else if (args[0] == "checkpoint" && args[1] == "restoreCheckpointPart" && args.size() == 4) {
|
||||
int count;
|
||||
if (!android::base::ParseInt(args[3], &count)) exit(EINVAL);
|
||||
checkStatus(vold->restoreCheckpointPart(args[2], count));
|
||||
} else if (args[0] == "checkpoint" && args[1] == "markBootAttempt" && args.size() == 2) {
|
||||
checkStatus(vold->markBootAttempt());
|
||||
} else if (args[0] == "checkpoint" && args[1] == "abortChanges" && args.size() == 2) {
|
||||
|
|
Loading…
Reference in a new issue