diff options
Diffstat (limited to 'tests/zfs-tests/include/libtest.shlib')
-rw-r--r-- | tests/zfs-tests/include/libtest.shlib | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/tests/zfs-tests/include/libtest.shlib b/tests/zfs-tests/include/libtest.shlib index 1dc6881b6..ab0cd5270 100644 --- a/tests/zfs-tests/include/libtest.shlib +++ b/tests/zfs-tests/include/libtest.shlib @@ -27,6 +27,7 @@ # Copyright (c) 2017, Lawrence Livermore National Security LLC. # Copyright (c) 2017, Datto Inc. All rights reserved. # Copyright (c) 2017, Open-E Inc. All rights reserved. +# Copyright (c) 2021, The FreeBSD Foundation. # Use is subject to license terms. # @@ -4194,6 +4195,25 @@ function get_arcstat # stat esac } +function punch_hole # offset length file +{ + typeset offset=$1 + typeset length=$2 + typeset file=$3 + + case $(uname) in + FreeBSD) + truncate -d -o $offset -l $length "$file" + ;; + Linux) + fallocate --punch-hole --offset $offset --length $length "$file" + ;; + *) + false + ;; + esac +} + # # Wait for the specified arcstat to reach non-zero quiescence. # If echo is 1 echo the value after reaching quiescence, otherwise |