fc_fallocate fail back to ftruncate under Linux

remotes/origin/fstore_storage_engine
YuQing 2022-12-11 12:43:24 +08:00
parent 86288bf99e
commit ee70efcd09
1 changed files with 12 additions and 1 deletions

View File

@ -485,7 +485,18 @@ static inline int fc_compare_int64(const int64_t n1, const int64_t n2)
} }
#ifdef OS_LINUX #ifdef OS_LINUX
#define fc_fallocate(fd, size) fallocate(fd, 0, 0, size) static inline int fc_fallocate(int fd, const int64_t size)
{
if (fallocate(fd, 0, 0, size) < 0) {
if (errno == EOPNOTSUPP) {
return ftruncate(fd, size);
}
return -1;
}
return 0;
}
#else #else
#define fc_fallocate(fd, size) ftruncate(fd, size) #define fc_fallocate(fd, size) ftruncate(fd, size)
#define posix_fadvise(fd, offset, len, advice) 0 #define posix_fadvise(fd, offset, len, advice) 0