Declare undefined symbols for fallocate function

This commit is contained in:
Takeshi Nakatani 2021-04-21 13:45:49 +00:00 committed by Andrew Gaul
parent e9eb248f2f
commit 1838f52e19

View File

@ -1614,13 +1614,6 @@ int FdEntity::UploadPendingMeta()
// ex. OSX // ex. OSX
// //
#ifndef HAVE_FALLOCATE #ifndef HAVE_FALLOCATE
// We need the symbols defined in fallocate, so we define them here.
// The definitions are copied from linux/falloc.h, but if HAVE_FALLOCATE is undefined,
// these values can be anything.
//
#define FALLOC_FL_PUNCH_HOLE 0x02 /* de-allocates range */
#define FALLOC_FL_KEEP_SIZE 0x01
static int fallocate(int /*fd*/, int /*mode*/, off_t /*offset*/, off_t /*len*/) static int fallocate(int /*fd*/, int /*mode*/, off_t /*offset*/, off_t /*len*/)
{ {
errno = ENOSYS; // This is a bad idea, but the caller can handle it simply. errno = ENOSYS; // This is a bad idea, but the caller can handle it simply.
@ -1628,6 +1621,20 @@ static int fallocate(int /*fd*/, int /*mode*/, off_t /*offset*/, off_t /*len*/)
} }
#endif // HAVE_FALLOCATE #endif // HAVE_FALLOCATE
// [NOTE]
// If HAVE_FALLOCATE is undefined, or versions prior to 2.6.38(fallocate function exists),
// following flags are undefined. Then we need these symbols defined in fallocate, so we
// define them here.
// The definitions are copied from linux/falloc.h, but if HAVE_FALLOCATE is undefined,
// these values can be anything.
//
#ifndef FALLOC_FL_PUNCH_HOLE
#define FALLOC_FL_PUNCH_HOLE 0x02 /* de-allocates range */
#endif
#ifndef FALLOC_FL_KEEP_SIZE
#define FALLOC_FL_KEEP_SIZE 0x01
#endif
// [NOTE] // [NOTE]
// This method punches an area(on cache file) that has no data at the time it is called. // This method punches an area(on cache file) that has no data at the time it is called.
// This is called to prevent the cache file from growing. // This is called to prevent the cache file from growing.