aboutsummaryrefslogtreecommitdiff
path: root/src/util
diff options
context:
space:
mode:
authorLuca Venturini <luca@yepa.com>2019-03-23 04:20:40 +0000
committerLuca Venturini <luca@yepa.com>2019-03-23 20:35:24 +0000
commit5d35ae3326624da3fe5dcb4047c9a7cec6665cab (patch)
tree2eb7299b17f29992f676bc707cf9a76259b5a51c /src/util
parent7b13c646457980f44599412f243694fa682a1abf (diff)
downloadbitcoin-5d35ae3326624da3fe5dcb4047c9a7cec6665cab.tar.xz
Handle the result of posix_fallocate system call
Diffstat (limited to 'src/util')
-rw-r--r--src/util/system.cpp7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/util/system.cpp b/src/util/system.cpp
index 9594dd81bf..708da7361c 100644
--- a/src/util/system.cpp
+++ b/src/util/system.cpp
@@ -1089,11 +1089,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] = {};