Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(218)

Side by Side Diff: delta_diff_generator.h

Issue 5548002: AU: When generating delta, use scratch off end of filesystem (Closed) Base URL: http://git.chromium.org/git/update_engine.git@master
Patch Set: Created 10 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | delta_diff_generator.cc » ('j') | delta_diff_generator.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium OS Authors. All rights reserved. 1 // Copyright (c) 2010 The Chromium OS Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CHROMEOS_PLATFORM_UPDATE_ENGINE_DELTA_DIFF_GENERATOR_H__ 5 #ifndef CHROMEOS_PLATFORM_UPDATE_ENGINE_DELTA_DIFF_GENERATOR_H__
6 #define CHROMEOS_PLATFORM_UPDATE_ENGINE_DELTA_DIFF_GENERATOR_H__ 6 #define CHROMEOS_PLATFORM_UPDATE_ENGINE_DELTA_DIFF_GENERATOR_H__
7 7
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 const std::string& private_key_path); 72 const std::string& private_key_path);
73 73
74 // These functions are public so that the unit tests can access them: 74 // These functions are public so that the unit tests can access them:
75 75
76 // Takes a graph, which is not a DAG, which represents the files just 76 // Takes a graph, which is not a DAG, which represents the files just
77 // read from disk, and converts it into a DAG by breaking all cycles 77 // read from disk, and converts it into a DAG by breaking all cycles
78 // and finding temp space to resolve broken edges. 78 // and finding temp space to resolve broken edges.
79 // The final order of the nodes is given in |final_order| 79 // The final order of the nodes is given in |final_order|
80 // Some files may need to be reread from disk, thus |fd| and 80 // Some files may need to be reread from disk, thus |fd| and
81 // |data_file_size| are be passed. 81 // |data_file_size| are be passed.
82 // If |scratch_vertex| is not kInvalidIndex, removes it from
83 // |final_order| before returning.
82 // Returns true on success. 84 // Returns true on success.
83 static bool ConvertGraphToDag(Graph* graph, 85 static bool ConvertGraphToDag(Graph* graph,
84 const std::string& new_root, 86 const std::string& new_root,
85 int fd, 87 int fd,
86 off_t* data_file_size, 88 off_t* data_file_size,
87 std::vector<Vertex::Index>* final_order); 89 std::vector<Vertex::Index>* final_order,
90 Vertex::Index scratch_vertex);
88 91
89 // Reads old_filename (if it exists) and a new_filename and determines 92 // Reads old_filename (if it exists) and a new_filename and determines
90 // the smallest way to encode this file for the diff. It stores 93 // the smallest way to encode this file for the diff. It stores
91 // necessary data in out_data and fills in out_op. 94 // necessary data in out_data and fills in out_op.
92 // If there's no change in old and new files, it creates a MOVE 95 // If there's no change in old and new files, it creates a MOVE
93 // operation. If there is a change, or the old file doesn't exist, 96 // operation. If there is a change, or the old file doesn't exist,
94 // the smallest of REPLACE, REPLACE_BZ, or BSDIFF wins. 97 // the smallest of REPLACE, REPLACE_BZ, or BSDIFF wins.
95 // new_filename must contain at least one byte. 98 // new_filename must contain at least one byte.
96 // Returns true on success. 99 // Returns true on success.
97 static bool ReadFileToDiff(const std::string& old_filename, 100 static bool ReadFileToDiff(const std::string& old_filename,
98 const std::string& new_filename, 101 const std::string& new_filename,
99 std::vector<char>* out_data, 102 std::vector<char>* out_data,
100 DeltaArchiveManifest_InstallOperation* out_op, 103 DeltaArchiveManifest_InstallOperation* out_op,
101 bool gather_extents); 104 bool gather_extents);
102 105
106 // Creates a dummy REPLACE_BZ node in the given vertex. This can be used
petkov 2010/12/02 05:04:06 I assume there's no difference if it's REPLACE_BZ
adlr 2010/12/02 19:21:41 Correct.
107 // to provide scratch space. The node should be marked invalid before
108 // writing all nodes to the output file.
109 static void CreateScratchNode(uint64_t start_block,
110 uint64_t num_blocks,
111 Vertex* vertex);
112
103 // Modifies blocks read by 'op' so that any blocks referred to by 113 // Modifies blocks read by 'op' so that any blocks referred to by
104 // 'remove_extents' are replaced with blocks from 'replace_extents'. 114 // 'remove_extents' are replaced with blocks from 'replace_extents'.
105 // 'remove_extents' and 'replace_extents' must be the same number of blocks. 115 // 'remove_extents' and 'replace_extents' must be the same number of blocks.
106 // Blocks will be substituted in the order listed in the vectors. 116 // Blocks will be substituted in the order listed in the vectors.
107 // E.g. if 'op' reads blocks 1, 2, 3, 4, 5, 6, 7, 8, remove_extents 117 // E.g. if 'op' reads blocks 1, 2, 3, 4, 5, 6, 7, 8, remove_extents
108 // contains blocks 6, 2, 3, 5, and replace blocks contains 118 // contains blocks 6, 2, 3, 5, and replace blocks contains
109 // 12, 13, 14, 15, then op will be changed to read from: 119 // 12, 13, 14, 15, then op will be changed to read from:
110 // 1, 13, 14, 4, 15, 12, 7, 8 120 // 1, 13, 14, 4, 15, 12, 7, 8
111 static void SubstituteBlocks(Vertex* vertex, 121 static void SubstituteBlocks(Vertex* vertex,
112 const std::vector<Extent>& remove_extents, 122 const std::vector<Extent>& remove_extents,
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
207 DISALLOW_IMPLICIT_CONSTRUCTORS(DeltaDiffGenerator); 217 DISALLOW_IMPLICIT_CONSTRUCTORS(DeltaDiffGenerator);
208 }; 218 };
209 219
210 extern const char* const kBsdiffPath; 220 extern const char* const kBsdiffPath;
211 extern const char* const kBspatchPath; 221 extern const char* const kBspatchPath;
212 extern const char* const kDeltaMagic; 222 extern const char* const kDeltaMagic;
213 223
214 }; // namespace chromeos_update_engine 224 }; // namespace chromeos_update_engine
215 225
216 #endif // CHROMEOS_PLATFORM_UPDATE_ENGINE_DELTA_DIFF_GENERATOR_H__ 226 #endif // CHROMEOS_PLATFORM_UPDATE_ENGINE_DELTA_DIFF_GENERATOR_H__
OLDNEW
« no previous file with comments | « no previous file | delta_diff_generator.cc » ('j') | delta_diff_generator.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698