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"; |
| 10 | // uint64 bom_offset; // Offset of protobuf DeltaArchiveManifest |
| 11 | // uint64 bom_size; // Sise of protobuf DeltaArchiveManifest |
| 12 | // |
| 13 | // // Data blobs for files, no specific format. The specific offset |
| 14 | // // and length of each data blob is recorded in the DeltaArchiveManifest. |
| 15 | // struct { |
| 16 | // char data[]; |
| 17 | // } blobs[]; |
| 18 | // |
| 19 | // // The Gzip compressed DeltaArchiveManifest |
| 20 | // char bom[]; |
| 21 | // }; |
| 22 | |
| 23 | // The DeltaArchiveManifest protobuf is an ordered list of File objects. |
| 24 | // These File objects are stored in a linear array in the |
| 25 | // DeltaArchiveManifest, each with a specific index. Each File object |
| 26 | // can contain children in its children list. Each child in the list |
| 27 | // has a name and an index. The index refers to the index within |
| 28 | // DeltaArchiveManifest.files. Thus, the DeltaArchiveManifest.files |
| 29 | // can be seen as a tree structure that mimicks the filesystem. |
| 30 | // The root object (the object an index 0) has no name, since names |
| 31 | // for children are stored in the parent. |
| 32 | |
| 33 | // The DeltaArchiveManifest will contain one File entry for each |
| 34 | // file that will be on the resultant filesystem. Because we have |
| 35 | // a tree structure, and children are ordered alphabetically within |
| 36 | // a parent, we can do log-time˜path lookup on a DeltaArchiveManifest |
| 37 | // object. We can also iterate through a DeltaArchiveManifest object |
| 38 | // using a preorder tree traversal to see each file in the |
| 39 | // DeltaArchiveManifest, seeing each directory before any of its children; |
| 40 | // this takes linear time. |
| 41 | |
| 42 | // Here's an example from Dan Erat showing DeltaArchiveManifest |
| 43 | // for a filesystem with files /bin/cat and /bin/ls.: |
| 44 | |
| 45 | // files[0] { // "/" directory |
| 46 | // children[0] { |
| 47 | // name "bin" |
| 48 | // index 1 |
| 49 | // } |
| 50 | // } |
| 51 | // files[1] { // "/bin" directory |
| 52 | // children[0] { |
| 53 | // name "cat" |
| 54 | // index 2 |
| 55 | // } |
| 56 | // children[1] { |
| 57 | // name "ls" |
| 58 | // index 3 |
| 59 | // } |
| 60 | // } |
| 61 | // files[2] { // "/bin/cat" |
| 62 | // } |
| 63 | // files[3] { // "/bin/ls" |
| 64 | // } |
| 65 | |
| 66 | // If a file has a data_format set, it should also have data_offset and |
| 67 | // data_length set. data_offset and data_length refer to a range of bytes |
| 68 | // in the delta update file itself which have the format specified by |
| 69 | // data_format. FULL and FULL_GZ mean the entire file is present (FULL_GZ, |
| 70 | // gzip compressed). BSDIFF means the old file with the same path should be |
| 71 | // patched with 'bspatch' to produce the desired output file. COURGETTE |
| 72 | // is not yet used, but it will be another binary diff format. |
| 73 | |
| 74 | // Directories should not have any data. |
| 75 | |
| 76 | // There are other types of files, too: symlinks, block and character devices, |
| 77 | // fifos, and sockets. Fifos and sockets contain no data. Block and |
| 78 | // character devices have data. It must be the format FULL or FULL_GZ, and |
| 79 | // the contents are a serialized LinuxDevice protobuf. Symlinks must either |
| 80 | // be FULL, FULL_GZ, or have no data. A symlink with no data is unchanged, |
| 81 | // and with data it's set to that data. |
| 82 | |
| 83 | // TODO(adlr): Add support for hard links; CL is prepared already. |
| 84 | // Extended attributes are unsupported at this time. |
| 85 | |
| 86 | package chromeos_update_engine; |
| 87 | |
| 88 | message DeltaArchiveManifest { |
| 89 | message File { |
| 90 | // This is st_mode from struct stat. It includes file type and permission |
| 91 | // bits. |
| 92 | optional uint32 mode = 1; |
| 93 | optional uint32 uid = 2; |
| 94 | optional uint32 gid = 3; |
| 95 | |
| 96 | // File Data, not for directories |
| 97 | enum DataFormat { |
| 98 | FULL = 0; // The data is the complete file |
| 99 | FULL_GZ = 1; // The data is the complete file gzipped |
| 100 | BSDIFF = 2; // The data is a bsdiff binary diff |
| 101 | COURGETTE = 3; // The data is a courgette binary diff |
| 102 | } |
| 103 | // If present, there is data associated with this File object and |
| 104 | // data_offset and data_size must be set. |
Andrew de los Reyes | 4fe15d0 | 2009-12-10 19:01:36 -0800 | [diff] [blame] | 105 | // If a file object doesn't have this set, it means the data is |
| 106 | // unchanged from the old version of the file. |
adlr@google.com | 3defe6a | 2009-12-04 20:57:17 +0000 | [diff] [blame] | 107 | optional DataFormat data_format = 4; |
| 108 | // The offset into the delta file where the data (if any) is stored |
| 109 | optional uint32 data_offset = 5; |
| 110 | // The length of the data in the delta file |
| 111 | optional uint32 data_length = 6; |
Andrew de los Reyes | e573399 | 2009-12-08 13:34:00 -0800 | [diff] [blame] | 112 | |
| 113 | // When a file is a hard link, hardlink_path exists and |
| 114 | // is the path within the DeltaArchiveManifest to the "original" file. |
| 115 | // When iterating through a DeltaArchiveManifest, you will be guaranteed |
| 116 | // to hit a hardlink only after you've hit the path to the first file. |
| 117 | // Directories can't be hardlinked. |
| 118 | optional string hardlink_path = 8; |
adlr@google.com | 3defe6a | 2009-12-04 20:57:17 +0000 | [diff] [blame] | 119 | |
| 120 | message Child { |
| 121 | // A File that's a directory (and only those types of File objects) |
| 122 | // will have exactly one Child submessage per child. |
| 123 | required string name = 1; // File name of child |
| 124 | |
| 125 | // Index into DeltaArchiveManifest.files for the File object of the child. |
| 126 | required uint32 index = 2; |
| 127 | } |
Andrew de los Reyes | e573399 | 2009-12-08 13:34:00 -0800 | [diff] [blame] | 128 | repeated Child children = 9; |
adlr@google.com | 3defe6a | 2009-12-04 20:57:17 +0000 | [diff] [blame] | 129 | } |
| 130 | repeated File files = 1; |
| 131 | } |
| 132 | |
| 133 | message LinuxDevice { |
| 134 | required int32 major = 1; |
| 135 | required int32 minor = 2; |
| 136 | } |