From 137d7633e008da289b981ef9f0c067c1655c9ce2 Mon Sep 17 00:00:00 2001 From: Savinda Senevirathne Date: Fri, 2 Apr 2021 10:36:29 +0530 Subject: [PATCH] Updated hpfs binary and its relevant hpcore changes. (#282) * Hpfs index file is updated to match the file with the hpfs version. * Added updated hpfs binary. * Version log changes because Plog is not initialized at the time of version init. --- src/hpfs/hpfs_mount.cpp | 5 +++-- src/util/version.cpp | 4 ++-- src/util/version.hpp | 4 ++++ test/bin/hpfs | Bin 309416 -> 309416 bytes 4 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/hpfs/hpfs_mount.cpp b/src/hpfs/hpfs_mount.cpp index 98add6a3..9822e3e9 100644 --- a/src/hpfs/hpfs_mount.cpp +++ b/src/hpfs/hpfs_mount.cpp @@ -5,6 +5,7 @@ #include "../util/h32.hpp" #include "../sc/sc.hpp" #include "../crypto.hpp" +#include "../util/version.hpp" namespace hpfs { @@ -523,7 +524,7 @@ namespace hpfs return -1; } close(fd); - seq_no = st.st_size / (sizeof(uint64_t) + sizeof(util::h32)); + seq_no = (st.st_size - version::HPFS_VERSION_BYTES_LEN) / (sizeof(uint64_t) + sizeof(util::h32)); return 0; } @@ -551,7 +552,7 @@ namespace hpfs return -1; } - const off_t offset = ((seq_no - 1) * (sizeof(uint64_t) + sizeof(util::h32))) + sizeof(uint64_t); + const off_t offset = version::HPFS_VERSION_BYTES_LEN + ((seq_no - 1) * (sizeof(uint64_t) + sizeof(util::h32))) + sizeof(uint64_t); // If calculated offset is beyond our file size means, // Requested seq_no is invalid or we do not have that seq_no in our hpfs log file. if (offset >= st.st_size) diff --git a/src/util/version.cpp b/src/util/version.cpp index 35e1e9b2..cf56557e 100644 --- a/src/util/version.cpp +++ b/src/util/version.cpp @@ -34,7 +34,7 @@ namespace version if (end == std::string::npos) { - LOG_ERROR << "Invalid version " << version; + std::cerr << "Invalid version " << version << std::endl; return -1; } @@ -45,7 +45,7 @@ namespace version if (end == std::string::npos) { - LOG_ERROR << "Invalid version " << version; + std::cerr << "Invalid version " << version << std::endl; return -1; } diff --git a/src/util/version.hpp b/src/util/version.hpp index 3fbd8c06..6c619eab 100644 --- a/src/util/version.hpp +++ b/src/util/version.hpp @@ -18,6 +18,10 @@ namespace version // 2 bytes each for 3 version components. 2 bytes reserved. constexpr const size_t VERSION_BYTES_LEN = 8; + // Hpfs version header length. This is currently same length as hpcore version header. + // This value needs to be updated when hpfs version header length changes. + constexpr const size_t HPFS_VERSION_BYTES_LEN = 8; + // Binary representations of the versions. (populated during version init) extern uint8_t HP_VERSION_BYTES[VERSION_BYTES_LEN]; extern uint8_t LEDGER_VERSION_BYTES[VERSION_BYTES_LEN]; diff --git a/test/bin/hpfs b/test/bin/hpfs index d2396e16d969913963bd9f6a53532cf5c6283164..06ec66cf7c2f8524999f3ae903213d73baf34940 100755 GIT binary patch delta 84 zcmZ4SQE0_Sp$#oeBA>KYzWO>}>_E`nOEGfw+hf!&2yWdxgGqsvan>(dJyy_FPd$AZ7w$=IyznEY^zw3|1eV delta 84 zcmZ4SQE0_Sp$#oeA~8bcho*l0Y`9D%C{X;M(FTDn>EAccU{YY6{DVhg^96PdR>l>R nFS3Yl7T`7Hm>eN0I@wWFyg662Jy(