2006-08-19 14:01:29 +00:00
|
|
|
#!/bin/sh
|
|
|
|
|
# Test cp --sparse=always
|
|
|
|
|
|
2010-01-01 10:56:28 +01:00
|
|
|
# Copyright (C) 2006-2010 Free Software Foundation, Inc.
|
2006-08-19 14:01:29 +00:00
|
|
|
|
2007-07-23 14:35:58 +02:00
|
|
|
# This program is free software: you can redistribute it and/or modify
|
2006-08-19 14:01:29 +00:00
|
|
|
# it under the terms of the GNU General Public License as published by
|
2007-07-23 14:35:58 +02:00
|
|
|
# the Free Software Foundation, either version 3 of the License, or
|
2006-08-19 14:01:29 +00:00
|
|
|
# (at your option) any later version.
|
|
|
|
|
|
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
|
|
|
|
|
|
# You should have received a copy of the GNU General Public License
|
2007-07-23 14:35:58 +02:00
|
|
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2006-08-19 14:01:29 +00:00
|
|
|
|
2010-11-14 11:05:05 +01:00
|
|
|
. "${srcdir=.}/init.sh"; path_prepend_ ../src
|
2010-11-17 21:35:31 +01:00
|
|
|
print_ver_ cp
|
2008-05-03 15:46:41 +02:00
|
|
|
require_sparse_support_
|
2006-08-19 14:01:29 +00:00
|
|
|
|
|
|
|
|
# Create a sparse file.
|
|
|
|
|
# It has to be at least 128K in order to be sparse on some systems.
|
|
|
|
|
# Make its size one larger than 128K, in order to tickle the
|
|
|
|
|
# bug in coreutils-6.0.
|
|
|
|
|
size=`expr 128 \* 1024 + 1`
|
2007-09-06 17:34:49 +02:00
|
|
|
dd bs=1 seek=$size of=sparse < /dev/null 2> /dev/null || framework_failure
|
2006-08-19 14:01:29 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
cp --sparse=always sparse copy || fail=1
|
|
|
|
|
|
|
|
|
|
# Ensure that the copy has the same block count as the original.
|
2007-03-13 19:51:47 +01:00
|
|
|
test `stat --printf %b copy` -le `stat --printf %b sparse` || fail=1
|
2006-08-19 14:01:29 +00:00
|
|
|
|
2009-08-01 19:36:48 +02:00
|
|
|
# Ensure that --sparse={always,never} with --reflink fail.
|
|
|
|
|
cp --sparse=always --reflink sparse copy && fail=1
|
|
|
|
|
cp --sparse=never --reflink sparse copy && fail=1
|
|
|
|
|
|
2008-09-07 10:31:27 +02:00
|
|
|
Exit $fail
|