aboutsummaryrefslogtreecommitdiff
path: root/src/util
diff options
context:
space:
mode:
authorMarcoFalke <falke.marco@gmail.com>2019-05-02 08:43:54 -0400
committerMarcoFalke <falke.marco@gmail.com>2019-05-02 08:43:57 -0400
commitc4560a7dfee94296e3fe7736423811c61356fbc5 (patch)
treeefc43229a887e4d187c8dfe35ed12caeda6d55b3 /src/util
parent0936f35f65ad778c1308f00b42b6182c7e64270f (diff)
parent5d35ae3326624da3fe5dcb4047c9a7cec6665cab (diff)
downloadbitcoin-c4560a7dfee94296e3fe7736423811c61356fbc5.tar.xz
Merge #15650: Handle the result of posix_fallocate system call
5d35ae3326 Handle the result of posix_fallocate system call (Luca Venturini) Pull request description: The system call `posix_fallocate` is not supported on some filesystems. - catches the result of posix_allocate and fall back to the default behaviour if the return value is different from 0 (success) Fixes #15624 ACKs for commit 5d35ae: MarcoFalke: utACK 5d35ae3326624da3fe5dcb4047c9a7cec6665cab sipa: utACK 5d35ae3326624da3fe5dcb4047c9a7cec6665cab, though the Yoda condition is an uncommon style in this project. hebasto: utACK 5d35ae3326624da3fe5dcb4047c9a7cec6665cab practicalswift: utACK 5d35ae3326624da3fe5dcb4047c9a7cec6665cab Tree-SHA512: 7ab3b35fb633926f28a58b2b07ffde8e31bb997c80a716b1b45ee716fe9ff4ddcef0a05810bd4423530e220cfc62f8925517d27a8b92b05a524272063e43f746
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 efd35bed55..6925bda4ef 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] = {};