mirror of
https://github.com/linux-apfs/apfstests.git
synced 2026-05-01 15:01:44 -07:00
1d315d6785
this is because $tmp.source_dir is not an empty dir. This change recursively deletes everything in $tmp.source_dir. Not required for $tmp.loop as it is used as a loopback mountpoint. the ignore external MKFS_OPTIONS change is no longer required, as _scratch_mkfs_xfs now handles conflicting options. Merge of master-melb:xfs-cmds:28863a by kenmcd. cleanup tmp and don't kill mkfs options
156 lines
4.1 KiB
Bash
Executable File
156 lines
4.1 KiB
Bash
Executable File
#! /bin/sh
|
|
# FS QA Test No. 073
|
|
#
|
|
# Test xfs_copy
|
|
#
|
|
#-----------------------------------------------------------------------
|
|
# Copyright (c) 2000-2003 Silicon Graphics, Inc. All Rights Reserved.
|
|
#-----------------------------------------------------------------------
|
|
#
|
|
# creator
|
|
owner=nathans@sgi.com
|
|
|
|
seq=`basename $0`
|
|
echo "QA output created by $seq"
|
|
|
|
here=`pwd`
|
|
tmp=/tmp/$$
|
|
status=1 # failure is the default!
|
|
_cleanup()
|
|
{
|
|
cd /
|
|
umount $SCRATCH_MNT 2>/dev/null
|
|
umount $tmp.loop 2>/dev/null
|
|
[ -d $tmp.loop ] && rmdir $tmp.loop
|
|
[ -d $tmp.source_dir ] && rm -rf $tmp.source_dir
|
|
rm -f $tmp.* /var/tmp/xfs_copy.log.*
|
|
}
|
|
trap "_cleanup; exit \$status" 0 1 2 3 15
|
|
|
|
_filter_copy()
|
|
{
|
|
sed -e "s,$1,<DEVIMAGE>,g" -e "s,$2,<FSIMAGE1>,g" \
|
|
-e "s,$3,<DEVIMAGE>,g" -e "s,$4,<FSIMAGE2>,g"
|
|
}
|
|
|
|
_filter_path()
|
|
{
|
|
sed -e "s,$1,<MNTPATH>,g" | LC_COLLATE=POSIX sort
|
|
}
|
|
|
|
_populate_scratch()
|
|
{
|
|
POSIXLY_CORRECT=yes \
|
|
dd if=/dev/zero of=$SCRATCH_MNT/big+attr count=1000 bs=4096
|
|
[ "$FAST_POPULATE" = true ] && return
|
|
echo $SCRATCH_MNT/big+attr | $here/src/fill2attr
|
|
$here/src/fill2fs --bytes=1048576 --filesize=4096 --stddev=0 --force \
|
|
--dir=$SCRATCH_MNT/fill --list=- > $tmp.manifest
|
|
}
|
|
|
|
_verify_copy()
|
|
{
|
|
target=$1
|
|
target_dir=$tmp.loop
|
|
source=$2
|
|
source_dir=$3
|
|
|
|
[ $source = $SCRATCH_DEV ] && _scratch_mount
|
|
|
|
echo checking new image
|
|
_check_xfs_filesystem $target none none
|
|
|
|
echo mounting new image on loopback
|
|
rmdir $target_dir 2>/dev/null
|
|
mkdir $target_dir
|
|
mount -t xfs -o loop $target $target_dir 2>/dev/null
|
|
if [ $? -ne 0 ]; then
|
|
echo retrying mount with nouuid option
|
|
mount -t xfs -o loop -o nouuid $target $target_dir
|
|
if [ $? -ne 0 ]; then
|
|
echo mount failed - evil!
|
|
return
|
|
fi
|
|
fi
|
|
|
|
echo comparing new image files to old
|
|
diff -Naur $source_dir $target_dir
|
|
|
|
echo comparing new image directories to old
|
|
find $source_dir | _filter_path $source_dir > $tmp.manifest1
|
|
find $target_dir | _filter_path $target_dir > $tmp.manifest2
|
|
[ -s $tmp.manifest1 ] || echo no directory output
|
|
diff -u $tmp.manifest1 $tmp.manifest2
|
|
|
|
echo comparing new image geometry to old
|
|
xfs_info $source_dir \
|
|
| _filter_copy $source $source_dir '/dev/loop.' '#' \
|
|
| tr -s ' ' \
|
|
> $tmp.geometry1
|
|
xfs_info $target_dir \
|
|
| _filter_copy $target $target_dir '/dev/loop.' '#' \
|
|
| tr -s ' ' \
|
|
> $tmp.geometry2
|
|
[ -s $tmp.geometry1 ] || echo no geometry output
|
|
diff -u $tmp.geometry1 $tmp.geometry2
|
|
|
|
echo unmounting and removing new image
|
|
umount $source $target
|
|
rm -f $target
|
|
}
|
|
|
|
# get standard environment, filters and checks
|
|
. ./common.rc
|
|
. ./common.filter
|
|
|
|
|
|
# real QA test starts here
|
|
_supported_fs xfs
|
|
_supported_os Linux
|
|
|
|
[ "$USE_EXTERNAL" = yes ] && _notrun "Cannot xfs_copy with external devices"
|
|
[ -x /usr/sbin/xfs_copy ] || _notrun "xfs_copy binary not yet installed"
|
|
|
|
_require_scratch
|
|
_require_loop
|
|
|
|
_scratch_mkfs_xfs -dsize=41m,agcount=2 | _filter_mkfs 2>/dev/null
|
|
_scratch_mount 2>/dev/null || _fail "initial scratch mount failed"
|
|
|
|
echo
|
|
echo === populating scratch device
|
|
_populate_scratch
|
|
umount $SCRATCH_MNT 2>/dev/null
|
|
|
|
echo
|
|
echo === copying scratch device to single target
|
|
xfs_copy $SCRATCH_DEV $tmp.image | _filter_copy '#' $tmp.image '#' '#'
|
|
_verify_copy $tmp.image $SCRATCH_DEV $SCRATCH_MNT
|
|
|
|
echo
|
|
echo === copying scratch device to single target, duplicate UUID
|
|
xfs_copy -d $SCRATCH_DEV $tmp.image | _filter_copy '#' $tmp.image '#' '#'
|
|
_verify_copy $tmp.image $SCRATCH_DEV $SCRATCH_MNT
|
|
|
|
echo
|
|
echo === copying scratch device to single target, large ro device
|
|
/sbin/mkfs.xfs -dfile,name=$tmp.source,size=100g | _filter_mkfs 2>/dev/null
|
|
rmdir $tmp.source_dir 2>/dev/null
|
|
mkdir $tmp.source_dir
|
|
mount -t xfs -o loop $tmp.source $tmp.source_dir
|
|
cp -a $here $tmp.source_dir
|
|
mount -t xfs -o remount,ro $tmp.source $tmp.source_dir
|
|
xfs_copy $tmp.source $tmp.image | _filter_copy '#' $tmp.image '#' '#'
|
|
_verify_copy $tmp.image $tmp.source $tmp.source_dir
|
|
|
|
echo
|
|
echo === copying scratch device to multiple targets
|
|
xfs_copy -L$tmp.log -b $SCRATCH_DEV $tmp.image1 $tmp.image2 \
|
|
| _filter_copy '#' $tmp.image1 '#' $tmp.image2
|
|
_verify_copy $tmp.image1 $SCRATCH_DEV $SCRATCH_MNT
|
|
_verify_copy $tmp.image2 $SCRATCH_DEV $SCRATCH_MNT
|
|
|
|
# success, all done
|
|
status=0
|
|
exit
|