From 693363fa6e980ebacb483cd82e951f821079f6a7 Mon Sep 17 00:00:00 2001 From: legend-hua Date: Wed, 14 Sep 2016 11:01:54 +0800 Subject: [PATCH] There was a error when building zfs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit issues: zfs build randfree_file.c: In function ‘main’: randfree_file.c:101: error: ‘FALLOC_FL_PUNCH_HOLE’ undeclared (first use in this function) solution: The FALLOC_FL_PUNCH_HOLE flag was introduced in the 2.6.38 kernel. So we need add the "#if #else #endif" for older kernel. --- tests/zfs-tests/cmd/randfree_file/randfree_file.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tests/zfs-tests/cmd/randfree_file/randfree_file.c b/tests/zfs-tests/cmd/randfree_file/randfree_file.c index ff30c24c09dc..05797448c90a 100644 --- a/tests/zfs-tests/cmd/randfree_file/randfree_file.c +++ b/tests/zfs-tests/cmd/randfree_file/randfree_file.c @@ -98,11 +98,18 @@ main(int argc, char *argv[]) free(buf); +#if defined(FALLOC_FL_PUNCH_HOLE) && defined(FALLOC_FL_KEEP_SIZE) if (fallocate(fd, FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE, start_off, off_len) < 0) { perror("fallocate"); return (1); } +#else /* !(defined(FALLOC_FL_PUNCH_HOLE) && defined(FALLOC_FL_KEEP_SIZE)) */ + { + perror("FALLOC_FL_PUNCH_HOLE unsupported"); + return (1); + } +#endif /* defined(FALLOC_FL_PUNCH_HOLE) && defined(FALLOC_FL_KEEP_SIZE) */ return (0); }