diff options
author | Luca Venturini <luca@yepa.com> | 2019-03-23 04:20:40 +0000 |
---|---|---|
committer | fanquake <fanquake@gmail.com> | 2019-09-24 07:53:29 +0800 |
commit | c52dd120fd6498ee73b7652e3b0e5380124a5502 (patch) | |
tree | a8b7857f3b90e397e070bb5d782680df656b7493 /src/util | |
parent | f792b25d1487efdfab4d78c96755a73d978abcc4 (diff) | |
download | bitcoin-c52dd120fd6498ee73b7652e3b0e5380124a5502.tar.xz |
Handle the result of posix_fallocate system call
Github-Pull: #15650
Rebased-From: 5d35ae3326624da3fe5dcb4047c9a7cec6665cab
Diffstat (limited to 'src/util')
-rw-r--r-- | src/util/system.cpp | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/src/util/system.cpp b/src/util/system.cpp index caa65f59ef..9765a18df1 100644 --- a/src/util/system.cpp +++ b/src/util/system.cpp @@ -1085,11 +1085,12 @@ void AllocateFileRange(FILE *file, unsigned int offset, unsigned int length) { fcntl(fileno(file), F_PREALLOCATE, &fst); } ftruncate(fileno(file), fst.fst_length); -#elif defined(__linux__) +#else + #if defined(__linux__) // Version using posix_fallocate off_t nEndPos = (off_t)offset + length; - posix_fallocate(fileno(file), 0, nEndPos); -#else + if (0 == posix_fallocate(fileno(file), 0, nEndPos)) return; + #endif // Fallback version // TODO: just write one byte per block static const char buf[65536] = {}; |