adlr@google.com | 3defe6a | 2009-12-04 20:57:17 +0000 | [diff] [blame] | 1 | // Copyright (c) 2009 The Chromium Authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | // Update file format: A delta update file contains all the deltas needed |
| 6 | // to update a system from one specific version to another specific |
| 7 | // version. The update format is represented by this struct pseudocode: |
| 8 | // struct delta_update_file { |
| 9 | // char magic[4] = "CrAU"; |
Andrew de los Reyes | 1e338b8 | 2010-01-22 14:57:27 -0800 | [diff] [blame] | 10 | // uint32 file_format_version = 1; |
| 11 | // uint64 manifest_size; // Size of protobuf DeltaArchiveManifest |
| 12 | // // The Bzip2 compressed DeltaArchiveManifest |
| 13 | // char manifest[]; |
adlr@google.com | 3defe6a | 2009-12-04 20:57:17 +0000 | [diff] [blame] | 14 | // |
| 15 | // // Data blobs for files, no specific format. The specific offset |
| 16 | // // and length of each data blob is recorded in the DeltaArchiveManifest. |
| 17 | // struct { |
| 18 | // char data[]; |
| 19 | // } blobs[]; |
| 20 | // |
adlr@google.com | 3defe6a | 2009-12-04 20:57:17 +0000 | [diff] [blame] | 21 | // }; |
| 22 | |
Andrew de los Reyes | 1e338b8 | 2010-01-22 14:57:27 -0800 | [diff] [blame] | 23 | // The DeltaArchiveManifest protobuf is an ordered list of InstallOperation |
| 24 | // objects. These objects are stored in a linear array in the |
| 25 | // DeltaArchiveManifest. Each operation is applied in order by the client. |
adlr@google.com | 3defe6a | 2009-12-04 20:57:17 +0000 | [diff] [blame] | 26 | |
Andrew de los Reyes | 1e338b8 | 2010-01-22 14:57:27 -0800 | [diff] [blame] | 27 | // The DeltaArchiveManifest also contains the initial and final |
| 28 | // checksums for the device. |
adlr@google.com | 3defe6a | 2009-12-04 20:57:17 +0000 | [diff] [blame] | 29 | |
Andrew de los Reyes | 1e338b8 | 2010-01-22 14:57:27 -0800 | [diff] [blame] | 30 | // The client will perform each InstallOperation in order, beginning even |
| 31 | // before the entire delta file is downloaded (but after at least the |
| 32 | // protobuf is downloaded). The types of operations are explained: |
| 33 | // - REPLACE: Replace the dst_extents on the drive with the attached data, |
| 34 | // zero padding out to block size. |
| 35 | // - REPLACE_BZ: bzip2-uncompress the attached data and write it into |
| 36 | // dst_extents on the drive, zero padding to block size. |
| 37 | // - MOVE: Copy the data in src_extents to dst_extents. Extents may overlap, |
| 38 | // so it may be desirable to read all src_extents data into memory before |
| 39 | // writing it out. |
| 40 | // - BSDIFF: Read src_length bytes from src_extents into memory, perform |
| 41 | // bspatch with attached data, write new data to dst_extents, zero padding |
| 42 | // to block size. |
adlr@google.com | 3defe6a | 2009-12-04 20:57:17 +0000 | [diff] [blame] | 43 | |
| 44 | package chromeos_update_engine; |
| 45 | |
Andrew de los Reyes | 1e338b8 | 2010-01-22 14:57:27 -0800 | [diff] [blame] | 46 | // Data is packed into blocks on disk, always starting from the beginning |
| 47 | // of the block. If a file's data is too large for one block, it overflows |
| 48 | // into another block, which may or may not be the following block on the |
| 49 | // physical partition. An ordered list of extents is another |
| 50 | // representation of an ordered list of blocks. For example, a file stored |
| 51 | // in blocks 9, 10, 11, 2, 18, 12 (in that order) would be stored in |
| 52 | // extents { {9, 3}, {2, 1}, {18, 1}, {12, 1} } (in that order). |
| 53 | // In general, files are stored sequentially on disk, so it's more efficient |
| 54 | // to use extents to encode the block lists (this is effectively |
| 55 | // run-length encoding). |
| 56 | // A sentinel value (kuint64max) as the start block denotes a sparse-hole |
| 57 | // in a file whose block-length is specified by num_blocks. |
adlr@google.com | 3defe6a | 2009-12-04 20:57:17 +0000 | [diff] [blame] | 58 | |
Andrew de los Reyes | 1e338b8 | 2010-01-22 14:57:27 -0800 | [diff] [blame] | 59 | message Extent { |
| 60 | optional uint64 start_block = 1; |
| 61 | optional uint64 num_blocks = 2; |
adlr@google.com | 3defe6a | 2009-12-04 20:57:17 +0000 | [diff] [blame] | 62 | } |
| 63 | |
Andrew de los Reyes | 1e338b8 | 2010-01-22 14:57:27 -0800 | [diff] [blame] | 64 | message DeltaArchiveManifest { |
| 65 | message InstallOperation { |
| 66 | enum Type { |
| 67 | REPLACE = 0; // Replace destination extents w/ attached data |
| 68 | REPLACE_BZ = 1; // Replace destination extents w/ attached bzipped data |
| 69 | MOVE = 2; // Move source extents to destination extents |
| 70 | BSDIFF = 3; // The data is a bsdiff binary diff |
| 71 | } |
| 72 | required Type type = 1; |
| 73 | // The offset into the delta file (after the protobuf) |
| 74 | // where the data (if any) is stored |
| 75 | optional uint32 data_offset = 2; |
| 76 | // The length of the data in the delta file |
| 77 | optional uint32 data_length = 3; |
| 78 | |
| 79 | // Ordered list of extents that are read from (if any) and written to. |
| 80 | repeated Extent src_extents = 4; |
| 81 | // Byte length of src, not necessarily block aligned. It's only used for |
| 82 | // BSDIFF, because we need to pass that external program the number |
| 83 | // of bytes to read from the blocks we pass it. |
| 84 | optional uint64 src_length = 5; |
| 85 | |
| 86 | repeated Extent dst_extents = 6; |
| 87 | // byte length of dst, not necessarily block aligned. It's only used for |
| 88 | // BSDIFF, because we need to fill in the rest of the last block |
| 89 | // that bsdiff writes with '\0' bytes. |
| 90 | optional uint64 dst_length = 7; |
| 91 | } |
| 92 | repeated InstallOperation install_operations = 1; |
Andrew de los Reyes | f4c7ef1 | 2010-04-30 10:37:00 -0700 | [diff] [blame^] | 93 | repeated InstallOperation kernel_install_operations = 2; |
Andrew de los Reyes | 1e338b8 | 2010-01-22 14:57:27 -0800 | [diff] [blame] | 94 | |
| 95 | // (At time of writing) usually 4096 |
Andrew de los Reyes | f4c7ef1 | 2010-04-30 10:37:00 -0700 | [diff] [blame^] | 96 | optional uint32 block_size = 3 [default = 4096]; |
Andrew de los Reyes | 1e338b8 | 2010-01-22 14:57:27 -0800 | [diff] [blame] | 97 | } |