2 # ensure that a sparse file is copied efficiently, by default
4 # Copyright (C) 2011-2021 Free Software Foundation, Inc.
6 # This program is free software: you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation, either version 3 of the License, or
9 # (at your option) any later version.
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with this program. If not, see <https://www.gnu.org/licenses/>.
19 .
"${srcdir=.}/tests/init.sh"; path_prepend_ .
/src
23 seek_data_capable_ sparse_chk ||
24 skip_
"this file system lacks SEEK_DATA support"
26 # Create a large-but-sparse file.
27 timeout
10 truncate
-s1T f ||
28 skip_
"unable to create a 1 TiB sparse file"
30 # Nothing can read (much less write) that many bytes in so little time.
31 timeout
10 cp --reflink=never f f2
33 if test $ret -eq 124; then # timeout
34 # Only fail if we allocated more data
35 # as we've seen SEEK_DATA taking 35s on some freebsd VMs
36 test $
(stat
-c%b f2
) -gt $
(stat
-c%b f
) && fail
=1 ||
37 skip_
"SEEK_DATA timed out"
38 elif test $ret -ne 0; then
42 # Ensure that the sparse file copied through SEEK_DATA has the same size
43 # in bytes as the original.
44 test "$(stat --printf %s f)" = "$(stat --printf %s f2)" || fail
=1