Loading fs_mgr/libsnapshot/include/libsnapshot/snapshot.h +17 −0 Original line number Diff line number Diff line Loading @@ -74,6 +74,12 @@ static constexpr const std::string_view kCowGroupName = "cow"; bool SourceCopyOperationIsClone(const chromeos_update_engine::InstallOperation& operation); enum class CreateResult : unsigned int { ERROR, CREATED, NOT_CREATED, }; enum class UpdateState : unsigned int { // No update or merge is in progress. None, Loading Loading @@ -246,6 +252,17 @@ class SnapshotManager final { // optional callback fires periodically to query progress via GetUpdateState. bool HandleImminentDataWipe(const std::function<void()>& callback = {}); // This method is only allowed in recovery and is used as a helper to // initialize the snapshot devices as a requirement to mount a snapshotted // /system in recovery. // This function returns: // - CreateResult::CREATED if snapshot devices were successfully created; // - CreateResult::NOT_CREATED if it was not necessary to create snapshot // devices; // - CreateResult::ERROR if a fatal error occurred, mounting /system should // be aborted. CreateResult RecoveryCreateSnapshotDevices(); // Dump debug information. bool Dump(std::ostream& os); Loading fs_mgr/libsnapshot/snapshot.cpp +32 −0 Original line number Diff line number Diff line Loading @@ -2356,5 +2356,37 @@ bool SnapshotManager::EnsureNoOverflowSnapshot(LockedFile* lock) { return true; } CreateResult SnapshotManager::RecoveryCreateSnapshotDevices() { if (!device_->IsRecovery()) { LOG(ERROR) << __func__ << " is only allowed in recovery."; return CreateResult::NOT_CREATED; } auto mount = EnsureMetadataMounted(); if (!mount || !mount->HasDevice()) { LOG(ERROR) << "Couldn't mount Metadata."; return CreateResult::NOT_CREATED; } auto state_file = GetStateFilePath(); if (access(state_file.c_str(), F_OK) != 0 && errno == ENOENT) { LOG(ERROR) << "Couldn't access state file."; return CreateResult::NOT_CREATED; } if (!NeedSnapshotsInFirstStageMount()) { return CreateResult::NOT_CREATED; } auto slot_suffix = device_->GetOtherSlotSuffix(); auto slot_number = SlotNumberForSlotSuffix(slot_suffix); auto super_path = device_->GetSuperDevice(slot_number); if (!CreateLogicalAndSnapshotPartitions(super_path)) { LOG(ERROR) << "Unable to map partitions."; return CreateResult::ERROR; } return CreateResult::CREATED; } } // namespace snapshot } // namespace android Loading
fs_mgr/libsnapshot/include/libsnapshot/snapshot.h +17 −0 Original line number Diff line number Diff line Loading @@ -74,6 +74,12 @@ static constexpr const std::string_view kCowGroupName = "cow"; bool SourceCopyOperationIsClone(const chromeos_update_engine::InstallOperation& operation); enum class CreateResult : unsigned int { ERROR, CREATED, NOT_CREATED, }; enum class UpdateState : unsigned int { // No update or merge is in progress. None, Loading Loading @@ -246,6 +252,17 @@ class SnapshotManager final { // optional callback fires periodically to query progress via GetUpdateState. bool HandleImminentDataWipe(const std::function<void()>& callback = {}); // This method is only allowed in recovery and is used as a helper to // initialize the snapshot devices as a requirement to mount a snapshotted // /system in recovery. // This function returns: // - CreateResult::CREATED if snapshot devices were successfully created; // - CreateResult::NOT_CREATED if it was not necessary to create snapshot // devices; // - CreateResult::ERROR if a fatal error occurred, mounting /system should // be aborted. CreateResult RecoveryCreateSnapshotDevices(); // Dump debug information. bool Dump(std::ostream& os); Loading
fs_mgr/libsnapshot/snapshot.cpp +32 −0 Original line number Diff line number Diff line Loading @@ -2356,5 +2356,37 @@ bool SnapshotManager::EnsureNoOverflowSnapshot(LockedFile* lock) { return true; } CreateResult SnapshotManager::RecoveryCreateSnapshotDevices() { if (!device_->IsRecovery()) { LOG(ERROR) << __func__ << " is only allowed in recovery."; return CreateResult::NOT_CREATED; } auto mount = EnsureMetadataMounted(); if (!mount || !mount->HasDevice()) { LOG(ERROR) << "Couldn't mount Metadata."; return CreateResult::NOT_CREATED; } auto state_file = GetStateFilePath(); if (access(state_file.c_str(), F_OK) != 0 && errno == ENOENT) { LOG(ERROR) << "Couldn't access state file."; return CreateResult::NOT_CREATED; } if (!NeedSnapshotsInFirstStageMount()) { return CreateResult::NOT_CREATED; } auto slot_suffix = device_->GetOtherSlotSuffix(); auto slot_number = SlotNumberForSlotSuffix(slot_suffix); auto super_path = device_->GetSuperDevice(slot_number); if (!CreateLogicalAndSnapshotPartitions(super_path)) { LOG(ERROR) << "Unable to map partitions."; return CreateResult::ERROR; } return CreateResult::CREATED; } } // namespace snapshot } // namespace android