AU: Delta Diff Generator
Adds a class that can take two root filesystem image and generate a
delta between them. Currently it's not very well tested, but this will
improve once the diff applicator is written.
Also, an executable to run the generator.
Other changes:
- Stop leaking loop devices in unittests
- extent mapper: support sparse files, ability to get FS block size
- AppendBlockToExtents support sparse files
- subprocess more verbose on errors
- add WriteAll to utils (WriteAll avoids short-write() returns)
- mkstemp wrapper for ease of use
- VectorIndexOf, finds index of an element in a vector
Review URL: http://codereview.chromium.org/891002
diff --git a/graph_utils.cc b/graph_utils.cc
index 79d5733..dd3cdcf 100644
--- a/graph_utils.cc
+++ b/graph_utils.cc
@@ -17,7 +17,8 @@
graph[edge.first].out_edges.find(edge.second)->second.extents;
for (vector<Extent>::const_iterator it = extents.begin();
it != extents.end(); ++it) {
- weight += it->num_blocks();
+ if (it->start_block() != kSparseHole)
+ weight += it->num_blocks();
}
return weight;
}
@@ -25,7 +26,15 @@
void AppendBlockToExtents(vector<Extent>* extents, uint64 block) {
if (!extents->empty()) {
Extent& extent = extents->back();
- if (extent.start_block() + extent.num_blocks() == block) {
+ if (block == kSparseHole) {
+ if (extent.start_block() == kSparseHole) {
+ // Extend sparse hole extent
+ extent.set_num_blocks(extent.num_blocks() + 1);
+ return;
+ } else {
+ // Create new extent below outer 'if'
+ }
+ } else if (extent.start_block() + extent.num_blocks() == block) {
extent.set_num_blocks(extent.num_blocks() + 1);
return;
}