futility: the show command can traverse all file types
It doesn't yet handle block devices, but it can display normal files
containing a entire BIOS image, a GBB, a VBLOCK, a .vbpubk, a .vblock,
and a firmware preamble (VbFirmwarePreambleHeader).
The command-line options are not well-documented.
BUG=chromium:224734
BRANCH=ToT
TEST=make runtests
Change-Id: I181f6331ae23599302bbaee3f270e8af9586cf06
Reviewed-on: https://chromium-review.googlesource.com/216032
Commit-Queue: Bill Richardson <wfrichar@chromium.org>
Tested-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
diff --git a/futility/futility.h b/futility/futility.h
index dfccf6f..8c2b809 100644
--- a/futility/futility.h
+++ b/futility/futility.h
@@ -3,10 +3,15 @@
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
-#include <stdint.h>
-
#ifndef VBOOT_REFERENCE_FUTILITY_H_
#define VBOOT_REFERENCE_FUTILITY_H_
+#include <stdint.h>
+
+#include "vboot_common.h"
+#include "gbb_header.h"
+
+/* This program */
+#define MYNAME "futility"
/* Here's a structure to define the commands that futility implements. */
struct futil_cmd_t {
@@ -46,4 +51,24 @@
#define BUILD_ASSERT(cond) _BA0_(cond, __LINE__)
#endif
+/* Fatal internal stupidness */
+#ifndef DIE
+#define DIE do { \
+ fprintf(stderr, MYNAME ": internal error at %s:%d\n", \
+ __FILE__, __LINE__); \
+ exit(1); \
+ } while (0)
+#endif
+
+
+/* Returns true if this looks enough like a GBB header to proceed. */
+int futil_looks_like_gbb(GoogleBinaryBlockHeader *gbb, uint32_t len);
+
+/*
+ * Returns true if the gbb header is valid (and optionally updates *maxlen).
+ * This doesn't verify the contents, though.
+ */
+int futil_valid_gbb_header(GoogleBinaryBlockHeader *gbb, uint32_t len,
+ uint32_t *maxlen);
+
#endif /* VBOOT_REFERENCE_FUTILITY_H_ */