Merge "libsnapshot: Add RecoveryCreateSnapshotDevices(device)" am: 548101de29

Change-Id: I79ea4a5da130a1dba8d1d201d974aac8c17f7c57
This commit is contained in:
Yifan Hong 2020-03-23 19:51:52 +00:00 committed by Automerger Merge Worker
commit 2d566d93b4
2 changed files with 20 additions and 0 deletions

View file

@ -230,8 +230,14 @@ class SnapshotManager final {
// devices;
// - CreateResult::ERROR if a fatal error occurred, mounting /system should
// be aborted.
// This function mounts /metadata when called, and unmounts /metadata upon
// return.
CreateResult RecoveryCreateSnapshotDevices();
// Same as RecoveryCreateSnapshotDevices(), but does not auto mount/umount
// /metadata.
CreateResult RecoveryCreateSnapshotDevices(const std::unique_ptr<AutoDevice>& metadata_device);
// Dump debug information.
bool Dump(std::ostream& os);

View file

@ -2587,6 +2587,20 @@ CreateResult SnapshotManager::RecoveryCreateSnapshotDevices() {
LOG(ERROR) << "Couldn't mount Metadata.";
return CreateResult::NOT_CREATED;
}
return RecoveryCreateSnapshotDevices(mount);
}
CreateResult SnapshotManager::RecoveryCreateSnapshotDevices(
const std::unique_ptr<AutoDevice>& metadata_device) {
if (!device_->IsRecovery()) {
LOG(ERROR) << __func__ << " is only allowed in recovery.";
return CreateResult::NOT_CREATED;
}
if (metadata_device == nullptr || !metadata_device->HasDevice()) {
LOG(ERROR) << "Metadata not mounted.";
return CreateResult::NOT_CREATED;
}
auto state_file = GetStateFilePath();
if (access(state_file.c_str(), F_OK) != 0 && errno == ENOENT) {