diff options
author | legend-hua <[email protected]> | 2016-09-18 06:20:10 +0800 |
---|---|---|
committer | Brian Behlendorf <[email protected]> | 2016-09-17 15:20:10 -0700 |
commit | a34f7ab332a66c2857b212abb6082fcc0e762519 (patch) | |
tree | 817448b6a3330029274655ffdded0152d576f3fc | |
parent | 30f3f2e13c01bf1c881b2f3bb1236fca9f87a8e5 (diff) |
Fix FALLOC_FL_PUNCH_HOLE use in randfree_file.c
The FALLOC_FL_PUNCH_HOLE flag was introduced in the 2.6.38
kernel. To prevent breaking the build on older systems wrap its use
in a conditional. When FALLOC_FL_PUNCH_HOLE isn't available
return a non-zero status and error message.
Reviewed-by: Brian Behlendorf <[email protected]>
Signed-off-by: legend-hua <[email protected]>
Closes #5101
-rw-r--r-- | tests/zfs-tests/cmd/randfree_file/randfree_file.c | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/tests/zfs-tests/cmd/randfree_file/randfree_file.c b/tests/zfs-tests/cmd/randfree_file/randfree_file.c index ff30c24c0..05797448c 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); } |