5 # The contents of this file are subject to the terms of the
6 # Common Development and Distribution License (the "License").
7 # You may not use this file except in compliance with the License.
9 # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 # or http://www.opensolaris.org/os/licensing.
11 # See the License for the specific language governing permissions
12 # and limitations under the License.
14 # When distributing Covered Code, include this CDDL HEADER in each
15 # file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 # If applicable, add the following below this CDDL HEADER, with the
17 # fields enclosed by brackets "[]" replaced with your own identifying
18 # information: Portions Copyright [yyyy] [name of copyright owner]
26 # Copyright 2007 Sun Microsystems, Inc. All rights reserved.
27 # Use is subject to license terms.
29 # ident "@(#)clean_mirror_common.kshlib 1.4 07/10/09 SMI"
32 # Most of the code related to the clearing of mirrors is duplicated in all
33 # the test cases below this directory, barring a few minor changes
34 # involving the device to be affected and the 'object' to use to mangle
35 # the contents of the mirror.
36 # This code is sourced into each of these test cases.
38 function overwrite_verify_mirror
40 typeset AFFECTED_DEVICE=$1
41 typeset OVERWRITING_DEVICE=$2
47 populate_dir $TESTDIR/file $FILE_COUNT $WRITE_COUNT $BLOCKSZ 0
48 while (( atfile < FILE_COUNT )); do
49 cksums[$atfile]=$($CKSUM ${TESTDIR}/file.${atfile})
50 (( atfile = atfile + 1 ))
53 # unmount and export before dd
54 log_must $UMOUNT $TESTDIR
55 log_must $ZPOOL export $TESTPOOL
57 # dd the primary side of the mirror
58 log_must $DD if=$OVERWRITING_DEVICE of=$(bsddevmap $AFFECTED_DEVICE) \
59 seek=8 bs=$DD_BLOCK count=$(( DD_COUNT - 8 )) conv=notrunc
62 log_must $ZPOOL import $TESTPOOL
65 typeset -i failedcount=0
66 while (( atfile < FILE_COUNT )); do
67 newcksum=$($CKSUM $TESTDIR/file.${atfile})
68 if [[ $newcksum != ${cksums[$atfile]} ]]; then
69 (( failedcount = failedcount + 1 ))
71 $RM -f ${files[$atfile]}
72 (( atfile = atfile + 1 ))
75 if (( $failedcount > 0 )); then
76 log_fail "of the $FILE_COUNT files $failedcount did not " \
77 "have the same checksum before and after."