Add support for bsdiff of file system metadata blocks
BUG=chromium-os:10188
TEST=Unit test, build delta update, apply to Mario and make sure it
boots with new version
Change-Id: I37b3fcc3c0e65e063cd95b0b3c9a5cd2261c98c9
Review URL: http://codereview.chromium.org/5684002
diff --git a/utils.h b/utils.h
index 34b862e..4979636 100644
--- a/utils.h
+++ b/utils.h
@@ -12,6 +12,7 @@
#include <string>
#include <vector>
+#include <ext2fs/ext2fs.h>
#include <glib.h>
#include "update_engine/action.h"
@@ -271,6 +272,17 @@
DISALLOW_COPY_AND_ASSIGN(ScopedFdCloser);
};
+// Utility class to close a file system
+class ScopedExt2fsCloser {
+ public:
+ explicit ScopedExt2fsCloser(ext2_filsys filsys) : filsys_(filsys) {}
+ ~ScopedExt2fsCloser() { ext2fs_close(filsys_); }
+
+ private:
+ ext2_filsys filsys_;
+ DISALLOW_COPY_AND_ASSIGN(ScopedExt2fsCloser);
+};
+
// Utility class to delete a file when it goes out of scope.
class ScopedPathUnlinker {
public:
@@ -389,6 +401,16 @@
} \
} while (0)
+#define TEST_AND_RETURN_FALSE_ERRCODE(_x) \
+ do { \
+ errcode_t _error = (_x); \
+ if (_error) { \
+ errno = _error; \
+ LOG(ERROR) << #_x " failed: " << _error; \
+ return false; \
+ } \
+ } while (0)
+
#endif // CHROMEOS_PLATFORM_UPDATE_ENGINE_UTILS_H__