From c339456514d12b1421b4ecb580ef2b35f6fd70bd Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Thu, 15 Aug 2013 23:01:59 -0700 Subject: [PATCH] client: guard fallocate with #ifdefs Only include linux header if it's linux. Only implement the fallocate method if FALLOC_FL_PUNCH_HOLE is defined. Signed-off-by: Sage Weil --- src/client/Client.cc | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/client/Client.cc b/src/client/Client.cc index fee0453e937f0..866b2117c6b4b 100644 --- a/src/client/Client.cc +++ b/src/client/Client.cc @@ -22,7 +22,10 @@ #include #include #include + +#if defined(__linux__) #include +#endif #include @@ -7686,6 +7689,8 @@ int Client::ll_fsync(Fh *fh, bool syncdataonly) return _fsync(fh, syncdataonly); } +#ifdef FALLOC_FL_PUNCH_HOLE + int Client::_fallocate(Fh *fh, int mode, int64_t offset, int64_t length) { if (offset < 0 || length <= 0) @@ -7757,6 +7762,15 @@ done: put_cap_ref(in, CEPH_CAP_FILE_WR); return r; } +#else + +int Client::_fallocate(Fh *fh, int mode, int64_t offset, int64_t length) +{ + return -EOPNOTSUPP; +} + +#endif + int Client::ll_fallocate(Fh *fh, int mode, loff_t offset, loff_t length) { -- 2.39.5