1#!/bin/ksh 2 3# 4# This file and its contents are supplied under the terms of the 5# Common Development and Distribution License ("CDDL"), version 1.0. 6# You may only use this file in accordance with the terms of version 7# 1.0 of the CDDL. 8# 9# A full copy of the text of the CDDL should have accompanied this 10# source. A copy of the CDDL is also available via the Internet at 11# http://www.illumos.org/license/CDDL. 12# 13 14# 15# Copyright (c) 2021 by Allan Jude. 16# 17 18. $STF_SUITE/include/libtest.shlib 19 20# 21# Description: 22# zdb -r <dataset> <path> <destination> 23# Will extract <path> (relative to <dataset>) to the file <destination> 24# Similar to -R, except it does the work for you to find each record 25# 26# Strategy: 27# 1. Create a pool 28# 2. Write some data to a file 29# 3. Extract the file 30# 4. Compare the file to the original 31# 32 33function cleanup 34{ 35 datasetexists $TESTPOOL && destroy_pool $TESTPOOL 36 rm $tmpfile 37} 38 39log_assert "Verify zdb -r <dataset> <path> <dest> extract the correct data." 40log_onexit cleanup 41init_data=$TESTDIR/file1 42tmpfile="$TEST_BASE_DIR/zdb-recover" 43write_count=8 44blksize=131072 45verify_runnable "global" 46verify_disk_count "$DISKS" 2 47 48default_mirror_setup_noexit $DISKS 49file_write -o create -w -f $init_data -b $blksize -c $write_count 50sync_pool $TESTPOOL 51 52output=$(zdb -r $TESTPOOL/$TESTFS file1 $tmpfile) 53log_must cmp $init_data $tmpfile 54 55log_pass "zdb -r <dataset> <path> <dest> extracts the correct data." 56