aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWladimir J. van der Laan <laanwj@protonmail.com>2020-01-23 20:42:58 +0100
committerWladimir J. van der Laan <laanwj@protonmail.com>2020-01-23 20:48:55 +0100
commit178a8346871e17d621ac780a5c47be65508ce176 (patch)
treefb3361f10012886e7a79d9e4a57b495fc5fef9a2
parent1b0afb71a2ad699c4d3cec9091dee717ea3c73a7 (diff)
parentdaf2fff236f8ebb75c785b33d2dd6dcd3cf86112 (diff)
Merge #17988: [0.19] Final backports for 0.19.1v0.19.1rc1
daf2fff236f8ebb75c785b33d2dd6dcd3cf86112 test: add missing #include to fix compiler errors (Karl-Johan Alm) c8ad23c52932cf33fac6e527ff18b5241ccceb04 bug-fix macos: give free bytes to F_PREALLOCATE (Karl-Johan Alm) Pull request description: We're about ready to do a [0.19.1 release](https://github.com/bitcoin/bitcoin/milestone/44); so I've opened this to collect the last remaining backports. If there's something that's been missed / or isn't tagged ["Needs backport (0.19)"](https://github.com/bitcoin/bitcoin/issues?q=is%3Aopen+label%3A%22Needs+backport+%280.19%29%22) that you think should be, please comment. Currently backports: * #17887 - bug-fix macos: give free bytes to F_PREALLOCATE * #17980 - test: add missing #include to fix compiler errors ACKs for top commit: laanwj: ACK daf2fff236f8ebb75c785b33d2dd6dcd3cf86112 Tree-SHA512: 8438f992d0c39315a4da4c3f8ab5c92acefada4b0ba5a5cec3775dea2541492d386bf4e7c9e76e1494a6d4cf16a9205287d27ffd23d9c3056f213d733605eeee
-rw-r--r--src/test/cuckoocache_tests.cpp1
-rw-r--r--src/util/system.cpp6
2 files changed, 5 insertions, 2 deletions
diff --git a/src/test/cuckoocache_tests.cpp b/src/test/cuckoocache_tests.cpp
index d38ede691a..2271aded1b 100644
--- a/src/test/cuckoocache_tests.cpp
+++ b/src/test/cuckoocache_tests.cpp
@@ -7,6 +7,7 @@
#include <test/setup_common.h>
#include <random.h>
#include <thread>
+#include <deque>
/** Test Suite for CuckooCache
*
diff --git a/src/util/system.cpp b/src/util/system.cpp
index bbd7c9940a..5a3c68aa0c 100644
--- a/src/util/system.cpp
+++ b/src/util/system.cpp
@@ -1088,17 +1088,19 @@ void AllocateFileRange(FILE *file, unsigned int offset, unsigned int length) {
SetEndOfFile(hFile);
#elif defined(MAC_OSX)
// OSX specific version
+ // NOTE: Contrary to other OS versions, the OSX version assumes that
+ // NOTE: offset is the size of the file.
fstore_t fst;
fst.fst_flags = F_ALLOCATECONTIG;
fst.fst_posmode = F_PEOFPOSMODE;
fst.fst_offset = 0;
- fst.fst_length = (off_t)offset + length;
+ fst.fst_length = length; // mac os fst_length takes the # of free bytes to allocate, not desired file size
fst.fst_bytesalloc = 0;
if (fcntl(fileno(file), F_PREALLOCATE, &fst) == -1) {
fst.fst_flags = F_ALLOCATEALL;
fcntl(fileno(file), F_PREALLOCATE, &fst);
}
- ftruncate(fileno(file), fst.fst_length);
+ ftruncate(fileno(file), static_cast<off_t>(offset) + length);
#else
#if defined(__linux__)
// Version using posix_fallocate