| Index: utils.h
|
| diff --git a/utils.h b/utils.h
|
| index 34b862e109195ec393e81fdbc9562679bb791a90..ad7946d75998ba45b458f29f863a2f7dbeb88d4a 100644
|
| --- a/utils.h
|
| +++ b/utils.h
|
| @@ -14,6 +14,8 @@
|
|
|
| #include <glib.h>
|
|
|
| +#include <ext2fs/ext2fs.h>
|
| +
|
| #include "update_engine/action.h"
|
| #include "update_engine/action_processor.h"
|
|
|
| @@ -271,6 +273,15 @@ class ScopedFdCloser {
|
| 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_;
|
| +};
|
| +
|
| // Utility class to delete a file when it goes out of scope.
|
| class ScopedPathUnlinker {
|
| public:
|
| @@ -389,6 +400,16 @@ class ScopedActionCompleter {
|
| } \
|
| } 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__
|
|
|