+static bool is_tdb1(struct tdb1_header *hdr, const void *buf, ssize_t rlen)
+{
+ /* This code assumes we've tried to read entire tdb1 header. */
+ BUILD_ASSERT(sizeof(*hdr) <= sizeof(struct tdb_header));
+
+ if (rlen < (ssize_t)sizeof(*hdr)) {
+ return false;
+ }
+
+ memcpy(hdr, buf, sizeof(*hdr));
+ if (strcmp(hdr->magic_food, TDB_MAGIC_FOOD) != 0)
+ return false;
+
+ return hdr->version == TDB1_VERSION
+ || hdr->version == TDB1_BYTEREV(TDB1_VERSION);
+}
+