1# vim: filetype=sh 2# 3# CDDL HEADER START 4# 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. 8# 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. 13# 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] 19# 20# CDDL HEADER END 21# 22 23# 24# Copyright 2007 Sun Microsystems, Inc. All rights reserved. 25# Use is subject to license terms. 26 27# Most of the code related to the clearing of mirrors is duplicated in all 28# the test cases below this directory, barring a few minor changes 29# involving the device to be affected and the 'object' to use to mangle 30# the contents of the mirror. 31# This code is sourced into each of these test cases. 32 33function overwrite_verify_mirror 34{ 35 typeset AFFECTED_DEVICE=$1 36 typeset OVERWRITING_DEVICE=$2 37 38 typeset atfile=0 39 set -A cksums 40 set -A newcksums 41 42 populate_dir $TESTDIR/file $FILE_COUNT $WRITE_COUNT $BLOCKSZ 0 43 while (( atfile < FILE_COUNT )); do 44 cksums[$atfile]=$($CKSUM ${TESTDIR}/file.${atfile}) 45 (( atfile = atfile + 1 )) 46 done 47 48 # unmount and export before dd 49 log_must $UMOUNT $TESTDIR 50 log_must $ZPOOL export $TESTPOOL 51 52 # dd the primary side of the mirror 53 log_must $DD if=$OVERWRITING_DEVICE of=$(bsddevmap $AFFECTED_DEVICE) \ 54 seek=8 bs=$DD_BLOCK count=$(( DD_COUNT - 8 )) conv=notrunc 55 56 # now remount 57 log_must $ZPOOL import $TESTPOOL 58 59 atfile=0 60 typeset -i failedcount=0 61 while (( atfile < FILE_COUNT )); do 62 newcksum=$($CKSUM $TESTDIR/file.${atfile}) 63 if [[ $newcksum != ${cksums[$atfile]} ]]; then 64 (( failedcount = failedcount + 1 )) 65 fi 66 $RM -f ${files[$atfile]} 67 (( atfile = atfile + 1 )) 68 done 69 70 if (( $failedcount > 0 )); then 71 log_fail "of the $FILE_COUNT files $failedcount did not " \ 72 "have the same checksum before and after." 73 fi 74} 75