AU: When generating delta, use scratch off end of filesystem

This idea was originally coded by Darin Petkov, but was lost during a
separate bug fix a while ago. This CL restores the functionality.

The partition limit is set to 1GiB right now.

BUG=7444
TEST=tested generating/applying on host and checking results; unittest; tested specific case 110.9->128.4 that release engineers saw

Change-Id: I28a9a8d7025b83ec20b91e97dce5b783fc060b7c

Review URL: http://codereview.chromium.org/5548002
diff --git a/delta_diff_generator.h b/delta_diff_generator.h
index 53d3f87..50a3a89 100644
--- a/delta_diff_generator.h
+++ b/delta_diff_generator.h
@@ -79,12 +79,15 @@
   // The final order of the nodes is given in |final_order|
   // Some files may need to be reread from disk, thus |fd| and
   // |data_file_size| are be passed.
+  // If |scratch_vertex| is not kInvalidIndex, removes it from
+  // |final_order| before returning.
   // Returns true on success.
   static bool ConvertGraphToDag(Graph* graph,
                                 const std::string& new_root,
                                 int fd,
                                 off_t* data_file_size,
-                                std::vector<Vertex::Index>* final_order);
+                                std::vector<Vertex::Index>* final_order,
+                                Vertex::Index scratch_vertex);
 
   // Reads old_filename (if it exists) and a new_filename and determines
   // the smallest way to encode this file for the diff. It stores
@@ -100,6 +103,14 @@
                              DeltaArchiveManifest_InstallOperation* out_op,
                              bool gather_extents);
 
+  // Creates a dummy REPLACE_BZ node in the given |vertex|. This can be used
+  // to provide scratch space. The node writes |num_blocks| blocks starting at
+  // |start_block|The node should be marked invalid before writing all nodes to
+  // the output file.
+  static void CreateScratchNode(uint64_t start_block,
+                                uint64_t num_blocks,
+                                Vertex* vertex);
+
   // Modifies blocks read by 'op' so that any blocks referred to by
   // 'remove_extents' are replaced with blocks from 'replace_extents'.
   // 'remove_extents' and 'replace_extents' must be the same number of blocks.