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/extent_mapper.h b/extent_mapper.h
index acdd418..b15cf4a 100755
--- a/extent_mapper.h
+++ b/extent_mapper.h
@@ -7,14 +7,27 @@
 
 #include <string>
 #include <vector>
+#include "base/basictypes.h"
 #include "update_engine/update_metadata.pb.h"
 
 namespace chromeos_update_engine {
 
 namespace extent_mapper {
 
+// Uses the FIBMAP ioctl to get all blocks used by a file and return them
+// as extents. Blocks are relative to the start of the filesystem. If
+// there is a sparse "hole" in the file, the blocks for that will be
+// represented by an extent whose start block is kSpareseHole.
+// The resulting extents are stored in 'out'. Keep in mind that while
+// the blocksize of a filesystem is often 4096 bytes, that is not always
+// the case, so one should consult GetFilesystemBlockSize(), too.
+// Returns true on success.
 bool ExtentsForFileFibmap(const std::string& path, std::vector<Extent>* out);
 
+// Puts the blocksize of the filesystem, as used by the FIBMAP ioctl, into
+// out_blocksize by using the FIGETBSZ ioctl. Returns true on success.
+bool GetFilesystemBlockSize(const std::string& path, uint32* out_blocksize);
+
 }  // namespace extent_mapper
 
 }  // namespace chromeos_update_engine