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_writer.cc b/extent_writer.cc
index 1ae565b..9f6fbf0 100644
--- a/extent_writer.cc
+++ b/extent_writer.cc
@@ -6,25 +6,12 @@
#include <errno.h>
#include <unistd.h>
#include <algorithm>
+#include "update_engine/utils.h"
using std::min;
namespace chromeos_update_engine {
-namespace {
-// Returns true on success.
-bool WriteAll(int fd, const void *buf, size_t count) {
- const char* c_buf = reinterpret_cast<const char*>(buf);
- ssize_t bytes_written = 0;
- while (bytes_written < static_cast<ssize_t>(count)) {
- ssize_t rc = write(fd, c_buf + bytes_written, count - bytes_written);
- TEST_AND_RETURN_FALSE_ERRNO(rc >= 0);
- bytes_written += rc;
- }
- return true;
-}
-}
-
bool DirectExtentWriter::Write(const void* bytes, size_t count) {
if (count == 0)
return true;
@@ -48,7 +35,7 @@
TEST_AND_RETURN_FALSE_ERRNO(lseek64(fd_, offset, SEEK_SET) !=
static_cast<off64_t>(-1));
TEST_AND_RETURN_FALSE(
- WriteAll(fd_, c_bytes + bytes_written, bytes_to_write));
+ utils::WriteAll(fd_, c_bytes + bytes_written, bytes_to_write));
}
bytes_written += bytes_to_write;
extent_bytes_written_ += bytes_to_write;