Log the file format of cros_install on postinstall action
This patch adds a new function to utils which determines the format
of a file based on magic constants on the header and returns a
human-readable description of it. This currently only supports ELF
files and is used to log the file format of the cros_install
binary on post-install.
BUG=chromium:356187
TEST=Unittests.
Change-Id: Ie6e91c3f5fa398c39894704db9071489560a8ff7
Reviewed-on: https://chromium-review.googlesource.com/191609
Tested-by: Alex Deymo <deymo@chromium.org>
Reviewed-by: Don Garrett <dgarrett@chromium.org>
Commit-Queue: Alex Deymo <deymo@chromium.org>
diff --git a/utils.h b/utils.h
index f404653..e129cbe 100644
--- a/utils.h
+++ b/utils.h
@@ -193,6 +193,11 @@
int* out_block_count,
int* out_block_size);
+
+// Returns a human-readable string with the file format based on magic constants
+// on the header of the file.
+std::string GetFileFormat(const std::string& path);
+
// Returns the string representation of the given UTC time.
// such as "11/14/2011 14:05:30 GMT".
std::string ToString(const base::Time utc_time);