Skip to content

Commit 5d35ae3

Browse files
committed
Handle the result of posix_fallocate system call
1 parent 7b13c64 commit 5d35ae3

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
@@ -1089,11 +1089,12 @@ void AllocateFileRange(FILE *file, unsigned int offset, unsigned int length) {
10891089
fcntl(fileno(file), F_PREALLOCATE, &fst);
10901090
}
10911091
ftruncate(fileno(file), fst.fst_length);
1092-
#elif defined(__linux__)
1092+
#else
1093+
#if defined(__linux__)
10931094
// Version using posix_fallocate
10941095
off_t nEndPos = (off_t)offset + length;
1095-
posix_fallocate(fileno(file), 0, nEndPos);
1096-
#else
1096+
if (0 == posix_fallocate(fileno(file), 0, nEndPos)) return;
1097+
#endif
10971098
// Fallback version
10981099
// TODO: just write one byte per block
10991100
static const char buf[65536] = {};

0 commit comments

Comments
 (0)