1// Copyright (C) 2019 The Android Open Source Project 2// 3// Licensed under the Apache License, Version 2.0 (the "License"); 4// you may not use this file except in compliance with the License. 5// You may obtain a copy of the License at 6// 7// http://www.apache.org/licenses/LICENSE-2.0 8// 9// Unless required by applicable law or agreed to in writing, software 10// distributed under the License is distributed on an "AS IS" BASIS, 11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12// See the License for the specific language governing permissions and 13// limitations under the License. 14 15syntax = "proto3"; 16package android.snapshot; 17 18option optimize_for = LITE_RUNTIME; 19 20// Next: 4 21enum SnapshotState { 22 // No snapshot is found. 23 NONE = 0; 24 25 // The snapshot has been created and possibly written to. Rollbacks are 26 // possible by destroying the snapshot. 27 CREATED = 1; 28 29 // Changes are being merged. No rollbacks are possible beyond this point. 30 MERGING = 2; 31 32 // Changes have been merged, Future reboots may map the base device 33 // directly. 34 MERGE_COMPLETED = 3; 35} 36 37// Next: 9 38message SnapshotStatus { 39 // Name of the snapshot. This is usually the name of the snapshotted 40 // logical partition; for example, "system_b". 41 string name = 1; 42 43 SnapshotState state = 2; 44 45 // Size of the full (base) device. 46 uint64 device_size = 3; 47 48 // Size of the snapshot. This is the sum of lengths of ranges in the base 49 // device that needs to be snapshotted during the update. 50 // This must be less than or equal to |device_size|. 51 // This value is 0 if no snapshot is needed for this device because 52 // no changes 53 uint64 snapshot_size = 4; 54 55 // Size of the "COW partition". A COW partition is a special logical 56 // partition represented in the super partition metadata. This partition and 57 // the "COW image" form the "COW device" that supports the snapshot device. 58 // 59 // When SnapshotManager creates a COW device, it first searches for unused 60 // blocks in the super partition, and use those before creating the COW 61 // image if the COW partition is not big enough. 62 // 63 // This value is 0 if no space in super is left for the COW partition. 64 // |cow_partition_size + cow_file_size| must not be zero if |snapshot_size| 65 // is non-zero. 66 uint64 cow_partition_size = 5; 67 68 // Size of the "COW file", or "COW image". A COW file / image is created 69 // when the "COW partition" is not big enough to store changes to the 70 // snapshot device. 71 // 72 // This value is 0 if |cow_partition_size| is big enough to hold all changes 73 // to the snapshot device. 74 uint64 cow_file_size = 6; 75 76 // Sectors allocated for the COW device. Recording this value right after 77 // the update and before the merge allows us to infer the progress of the 78 // merge process. 79 // This is non-zero when |state| == MERGING or MERGE_COMPLETED. 80 uint64 sectors_allocated = 7; 81 82 // Metadata sectors allocated for the COW device. Recording this value right 83 // before the update and before the merge allows us to infer the progress of 84 // the merge process. 85 // This is non-zero when |state| == MERGING or MERGE_COMPLETED. 86 uint64 metadata_sectors = 8; 87} 88 89// Next: 8 90enum UpdateState { 91 // No update or merge is in progress. 92 None = 0; 93 94 // An update is applying; snapshots may already exist. 95 Initiated = 1; 96 97 // An update is pending, but has not been successfully booted yet. 98 Unverified = 2; 99 100 // The kernel is merging in the background. 101 Merging = 3; 102 103 // Post-merge cleanup steps could not be completed due to a transient 104 // error, but the next reboot will finish any pending operations. 105 MergeNeedsReboot = 4; 106 107 // Merging is complete, and needs to be acknowledged. 108 MergeCompleted = 5; 109 110 // Merging failed due to an unrecoverable error. 111 MergeFailed = 6; 112 113 // The update was implicitly cancelled, either by a rollback or a flash 114 // operation via fastboot. This state can only be returned by WaitForMerge. 115 Cancelled = 7; 116}; 117 118// Next: 5 119message SnapshotUpdateStatus { 120 UpdateState state = 1; 121 122 // Total number of sectors allocated in the COW files before performing the 123 // merge operation. This field is used to keep track of the total number 124 // of sectors modified to monitor and show the progress of the merge during 125 // an update. 126 uint64 sectors_allocated = 2; 127 128 // Total number of sectors of all the snapshot devices. 129 uint64 total_sectors = 3; 130 131 // Sectors allocated for metadata in all the snapshot devices. 132 uint64 metadata_sectors = 4; 133} 134 135// Next: 4 136message SnapshotMergeReport { 137 // Status of the update after the merge attempts. 138 UpdateState state = 1; 139 140 // Number of reboots that occurred after issuing and before completeing the 141 // merge of all the snapshot devices. 142 int32 resume_count = 2; 143 144 // Total size of all the COW images before the update. 145 uint64 cow_file_size = 3; 146} 147