Skip to content

Commit c4560a7

Browse files
author
MarcoFalke
committed
Merge #15650: Handle the result of posix_fallocate system call
5d35ae3 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 5d35ae3 sipa: utACK 5d35ae3, though the Yoda condition is an uncommon style in this project. hebasto: utACK 5d35ae3 practicalswift: utACK 5d35ae3 Tree-SHA512: 7ab3b35fb633926f28a58b2b07ffde8e31bb997c80a716b1b45ee716fe9ff4ddcef0a05810bd4423530e220cfc62f8925517d27a8b92b05a524272063e43f746
2 parents 0936f35 + 5d35ae3 commit c4560a7

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/util/system.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1085,11 +1085,12 @@ void AllocateFileRange(FILE *file, unsigned int offset, unsigned int length) {
10851085
fcntl(fileno(file), F_PREALLOCATE, &fst);
10861086
}
10871087
ftruncate(fileno(file), fst.fst_length);
1088-
#elif defined(__linux__)
1088+
#else
1089+
#if defined(__linux__)
10891090
// Version using posix_fallocate
10901091
off_t nEndPos = (off_t)offset + length;
1091-
posix_fallocate(fileno(file), 0, nEndPos);
1092-
#else
1092+
if (0 == posix_fallocate(fileno(file), 0, nEndPos)) return;
1093+
#endif
10931094
// Fallback version
10941095
// TODO: just write one byte per block
10951096
static const char buf[65536] = {};

0 commit comments

Comments
 (0)