2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2000-2003,2008 Silicon Graphics, Inc. All Rights Reserved.
10 _begin_fstest copy auto
12 # Import common functions.
16 # don't put fs images in /tmp
19 # Override the default cleanup function.
23 _scratch_unmount 2>/dev/null
24 umount $imgs.loop 2>/dev/null
25 [ -d $imgs.loop ] && rmdir $imgs.loop
26 umount $imgs.source_dir 2>/dev/null
27 [ -d $imgs.source_dir ] && rm -rf $imgs.source_dir
28 rm -f $imgs.* $tmp.* /var/tmp/xfs_copy.log.*
33 sed -e "s,$1,<DEVIMAGE>,g" -e "s,$2,<FSIMAGE1>,g" \
34 -e "s,$3,<DEVIMAGE>,g" -e "s,$4,<FSIMAGE2>,g"
39 sed -e "s,$1,<MNTPATH>,g" | LC_COLLATE=POSIX sort
45 dd if=/dev/zero of=$SCRATCH_MNT/big+attr count=1000 bs=4096
46 [ "$FAST_POPULATE" = true ] && return
47 echo $SCRATCH_MNT/big+attr | $here/src/fill2attr
48 $here/src/fill2fs --bytes=1048576 --filesize=4096 --stddev=0 --force \
49 --dir=$SCRATCH_MNT/fill --list=- > $tmp.manifest
59 [ $source = $SCRATCH_DEV ] && _scratch_mount
61 echo checking new image
62 _check_xfs_filesystem $target none none
64 echo mounting new image on loopback
65 rmdir $target_dir 2>/dev/null
68 mount -t xfs -o loop $target $target_dir 2>/dev/null
70 echo retrying mount with nouuid option >>$seqres.full
71 mount -t xfs -o loop -o nouuid $target $target_dir
73 echo mount failed - evil!
78 echo comparing new image files to old
79 diff -Naur $source_dir $target_dir
81 echo comparing new image directories to old
82 find $source_dir | _filter_path $source_dir > $tmp.manifest1
83 find $target_dir | _filter_path $target_dir > $tmp.manifest2
84 [ -s $tmp.manifest1 ] || echo no directory output
85 diff -u $tmp.manifest1 $tmp.manifest2
87 echo comparing new image geometry to old
88 $XFS_INFO_PROG $source_dir \
89 | _filter_copy $source $source_dir '/dev/loop.' '#' \
92 $XFS_INFO_PROG $target_dir \
93 | _filter_copy $target $target_dir '/dev/loop.' '#' \
96 [ -s $tmp.geometry1 ] || echo no geometry output
97 diff -u $tmp.geometry1 $tmp.geometry2
99 echo unmounting and removing new image
101 umount $target_dir > /dev/null 2>&1
105 # real QA test starts here
113 _scratch_mkfs_xfs -dsize=41m,agcount=2 >>$seqres.full 2>&1
117 echo === populating scratch device
119 _scratch_unmount 2>/dev/null
122 echo === copying scratch device to single target
123 $XFS_COPY_PROG $SCRATCH_DEV $imgs.image | _filter_copy '#' $imgs.image '#' '#'
124 _verify_copy $imgs.image $SCRATCH_DEV $SCRATCH_MNT
127 echo === copying scratch device to single target, duplicate UUID
128 $XFS_COPY_PROG -d $SCRATCH_DEV $imgs.image | _filter_copy '#' $imgs.image '#' '#'
129 _verify_copy $imgs.image $SCRATCH_DEV $SCRATCH_MNT
132 echo === copying scratch device to single target, large ro device
133 ${MKFS_XFS_PROG} -dfile,name=$imgs.source,size=100g \
134 | _filter_mkfs 2>/dev/null
135 rmdir $imgs.source_dir 2>/dev/null
136 mkdir $imgs.source_dir
138 mount -t xfs -o loop $imgs.source $imgs.source_dir
139 loop2=`mount | grep $imgs.source | grep -o -e 'loop=.*[^),]' | grep -o -e '/.*$'`
140 cp -a $here $imgs.source_dir
141 mount -t xfs -o remount,ro $imgs.source $imgs.source_dir
142 $XFS_COPY_PROG $imgs.source $imgs.image | _filter_copy '#' $imgs.image '#' '#'
143 _verify_copy $imgs.image $imgs.source $imgs.source_dir
147 # We're done with the nested loop mount, now we have to clean
148 # up the pieces that mount is incapable of doing.
149 losetup -d $loop2 > /dev/null 2>&1
152 echo === copying scratch device to multiple targets
153 $XFS_COPY_PROG -L$imgs.log -b $SCRATCH_DEV $imgs.image1 $imgs.image2 \
154 | _filter_copy '#' $imgs.image1 '#' $imgs.image2
155 _verify_copy $imgs.image1 $SCRATCH_DEV $SCRATCH_MNT
156 _verify_copy $imgs.image2 $SCRATCH_DEV $SCRATCH_MNT