From cf8ea4cbc75003f797b5f6ebf7fe0c841100c7aa Mon Sep 17 00:00:00 2001 From: "sanghyeok.oh" Date: Mon, 28 Oct 2019 16:23:12 +0900 Subject: [PATCH] printer: print FileIdentifier Change-Id: Ia993cd3739f74920e3dedceeb4a58de1e967b326 Signed-off-by: sanghyeok.oh (cherry picked from commit 87cae30fd5842acc83ababd378873b3182c11f02) --- src/internal/print_content.hpp | 3 +++ src/internal/storage_backend_serialized.cpp | 14 +++++++++++--- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/src/internal/print_content.hpp b/src/internal/print_content.hpp index 78f6381..2e93ea6 100644 --- a/src/internal/print_content.hpp +++ b/src/internal/print_content.hpp @@ -25,6 +25,9 @@ void use_xml_format(const bool xml); } namespace FB { +const unsigned int FB_ID_OFFSET = 4; +const unsigned int FB_ID_SIZE = 4; + std::ostream &operator<<(std::ostream &stream, const FB::File &file); } diff --git a/src/internal/storage_backend_serialized.cpp b/src/internal/storage_backend_serialized.cpp index 4859951..929f4d5 100644 --- a/src/internal/storage_backend_serialized.cpp +++ b/src/internal/storage_backend_serialized.cpp @@ -247,12 +247,20 @@ bool StorageBackendSerialized::StorageBackendSerializedImpl::init(const char *fi return err("mmap"); auto mmapGuard = transaction_guard::makeGuard([&] () { releaseMMap(); }); - if (verify) { auto verifier = flatbuffers::Verifier(mem, length); if (!FB::VerifyFileBuffer(verifier) || !FB::FileBufferHasIdentifier(mem)) { - tslog::log_error("verification of serialized data: failed\n"); - return false; + char fid[FB::FB_ID_SIZE + 1] = {0, }; + strncpy(fid, (const char *)(mem + FB::FB_ID_OFFSET), FB::FB_ID_SIZE); + + if (strcmp(fid, "LDP1") == 0) { + tslog::log_error("verification of serialized data: not available\n"); + tslog::log_error("header ID : ", FB::FileIdentifier(), "\n"); + tslog::log_error("serialized data ID : ", fid, "\n"); + } else { + tslog::log_error("verification of serialized data: failed\n"); + return false; + } } } -- 2.7.4