The function create_cloned_devices() takes two devices, creates a filesystem using mkfs, and clones the content from one device to another using device dump. Signed-off-by: Anand Jain <anand.jain@xxxxxxxxxx> --- common/btrfs | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/common/btrfs b/common/btrfs index 5cba9b16b4de..61d5812d49d9 100644 --- a/common/btrfs +++ b/common/btrfs @@ -826,3 +826,25 @@ check_fsid() echo -e -n "Tempfsid status:\t" cat /sys/fs/btrfs/$tempfsid/temp_fsid } + +create_cloned_devices() +{ + local dev1=$1 + local dev2=$2 + + [[ -z $dev1 || -z $dev2 ]] && \ + _fail "BUGGY code, create_cloned_devices needs arg1 arg3" + + echo -n Creating cloned device... + _mkfs_dev -fq -b $((1024 * 1024 * 300)) $dev1 + + _mount $dev1 $SCRATCH_MNT + + $XFS_IO_PROG -fc 'pwrite -S 0x61 0 9000' $SCRATCH_MNT/foo | \ + _filter_xfs_io + umount $SCRATCH_MNT + # device dump of $dev1 to $dev2 + dd if=$dev1 of=$dev2 bs=300M count=1 conv=fsync status=none || \ + _fail "dd failed: $?" + echo done +} -- 2.39.3