diff --git a/src/hpfs/hpfs_mount.cpp b/src/hpfs/hpfs_mount.cpp index 385b4b79..caace69e 100644 --- a/src/hpfs/hpfs_mount.cpp +++ b/src/hpfs/hpfs_mount.cpp @@ -15,6 +15,7 @@ namespace hpfs constexpr const char *RO_SESSION_HMAP = "/::hpfs.ro.hmap."; constexpr const char *HMAP_HASH = "::hpfs.hmap.hash"; constexpr const char *HMAP_CHILDREN = "::hpfs.hmap.children"; + constexpr const char *INDEX_UPDATE = "/::hpfs.index"; constexpr ino_t ROOT_INO = 1; constexpr uint16_t PROCESS_INIT_TIMEOUT = 2000; @@ -391,4 +392,24 @@ namespace hpfs } } + int hpfs_mount::update_hpfs_log_index() + { + const std::string index_file = mount_dir + INDEX_UPDATE; + + const int fd = open(index_file.c_str(), O_RDWR); + if (fd == -1) + return -1; + + // We just send empty buffer with write size 1 to invoke the hpfs index update. + // Write syscall isn't invoking with write size 0. + if (write(fd, "", 1) == -1) + { + close(fd); + return -1; + } + + close(fd); + return 0; + } + } // namespace hpfs \ No newline at end of file diff --git a/src/hpfs/hpfs_mount.hpp b/src/hpfs/hpfs_mount.hpp index 67022fb5..18bea158 100644 --- a/src/hpfs/hpfs_mount.hpp +++ b/src/hpfs/hpfs_mount.hpp @@ -67,6 +67,7 @@ namespace hpfs const std::string physical_path(std::string_view session_name, std::string_view vpath); const util::h32 get_parent_hash(const std::string &parent_vpath); void set_parent_hash(const std::string &parent_vpath, const util::h32 new_state); + int update_hpfs_log_index(); }; } // namespace hpfs diff --git a/src/ledger/ledger.cpp b/src/ledger/ledger.cpp index a8fa9e73..ecfd43b4 100644 --- a/src/ledger/ledger.cpp +++ b/src/ledger/ledger.cpp @@ -159,6 +159,13 @@ namespace ledger // Update the last shard hash and shard seqence number tracker when a new ledger is created. ctx.set_last_primary_shard_id(p2p::sequence_hash{primary_shard_seq_no, last_primary_shard_hash}); + // Update the hpfs log index file only in full history mode. + if (conf::cfg.node.history == conf::HISTORY::FULL && sc::contract_fs.update_hpfs_log_index() == -1) + { + LOG_ERROR << errno << ": Error updating the log index file."; + return -1; + } + //Remove old shards that exceeds max shard range. if (conf::cfg.node.history == conf::HISTORY::CUSTOM && primary_shard_seq_no >= conf::cfg.node.history_config.max_primary_shards) { diff --git a/test/bin/hpfs b/test/bin/hpfs index c2a5b7dc..e25f415b 100755 Binary files a/test/bin/hpfs and b/test/bin/hpfs differ