From dd21e6f848ce743ca6d61e1ea6acf116a5a6b383 Mon Sep 17 00:00:00 2001 From: Zygo Blaxell Date: Thu, 1 Dec 2016 22:12:38 -0500 Subject: [PATCH] crucible: add missing template specializations of pwrite helper functions I got a little too enthusiastic when redacting the code, and removed some overloaded functions bees was using. C++ silently found replacements, and the result was a bug that prevented any data from being persisted from the hash table. Fixes: https://github.com/Zygo/bees/issues/7 --- include/crucible/fd.h | 3 +++ lib/fd.cc | 21 +++++++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/include/crucible/fd.h b/include/crucible/fd.h index bd4265e..685babd 100644 --- a/include/crucible/fd.h +++ b/include/crucible/fd.h @@ -120,6 +120,9 @@ namespace crucible { template<> void pread_or_die(int fd, string& str, off_t offset); template<> void pread_or_die>(int fd, vector& str, off_t offset); template<> void pread_or_die>(int fd, vector& str, off_t offset); + template<> void pwrite_or_die(int fd, const string& str, off_t offset); + template<> void pwrite_or_die>(int fd, const vector& str, off_t offset); + template<> void pwrite_or_die>(int fd, const vector& str, off_t offset); // A different approach to reading a simple string string read_string(int fd, size_t size); diff --git a/lib/fd.cc b/lib/fd.cc index 4216b4f..881f98a 100644 --- a/lib/fd.cc +++ b/lib/fd.cc @@ -426,6 +426,27 @@ namespace crucible { return pread_or_die(fd, text.data(), text.size(), offset); } + template<> + void + pwrite_or_die>(int fd, const vector &text, off_t offset) + { + return pwrite_or_die(fd, text.data(), text.size(), offset); + } + + template<> + void + pwrite_or_die>(int fd, const vector &text, off_t offset) + { + return pwrite_or_die(fd, text.data(), text.size(), offset); + } + + template<> + void + pwrite_or_die(int fd, const string &text, off_t offset) + { + return pwrite_or_die(fd, text.data(), text.size(), offset); + } + Stat::Stat() { memset_zero(this);