12fae26bdSAlan Somers# vim: filetype=sh 22fae26bdSAlan Somers# 32fae26bdSAlan Somers# CDDL HEADER START 42fae26bdSAlan Somers# 52fae26bdSAlan Somers# The contents of this file are subject to the terms of the 62fae26bdSAlan Somers# Common Development and Distribution License (the "License"). 72fae26bdSAlan Somers# You may not use this file except in compliance with the License. 82fae26bdSAlan Somers# 92fae26bdSAlan Somers# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 102fae26bdSAlan Somers# or http://www.opensolaris.org/os/licensing. 112fae26bdSAlan Somers# See the License for the specific language governing permissions 122fae26bdSAlan Somers# and limitations under the License. 132fae26bdSAlan Somers# 142fae26bdSAlan Somers# When distributing Covered Code, include this CDDL HEADER in each 152fae26bdSAlan Somers# file and include the License file at usr/src/OPENSOLARIS.LICENSE. 162fae26bdSAlan Somers# If applicable, add the following below this CDDL HEADER, with the 172fae26bdSAlan Somers# fields enclosed by brackets "[]" replaced with your own identifying 182fae26bdSAlan Somers# information: Portions Copyright [yyyy] [name of copyright owner] 192fae26bdSAlan Somers# 202fae26bdSAlan Somers# CDDL HEADER END 212fae26bdSAlan Somers# 222fae26bdSAlan Somers 232fae26bdSAlan Somers# 242fae26bdSAlan Somers# Copyright 2007 Sun Microsystems, Inc. All rights reserved. 252fae26bdSAlan Somers# Use is subject to license terms. 262fae26bdSAlan Somers 272fae26bdSAlan Somersfunction overwrite_verify_mirror 282fae26bdSAlan Somers{ 292fae26bdSAlan Somers typeset POOL=$1 302fae26bdSAlan Somers typeset AFFECTED_DEVICE=$2 312fae26bdSAlan Somers typeset OVERWRITING_DEVICE=$3 322fae26bdSAlan Somers 332fae26bdSAlan Somers typeset atfile=0 342fae26bdSAlan Somers set -A files 352fae26bdSAlan Somers set -A cksums 362fae26bdSAlan Somers set -A newcksums 372fae26bdSAlan Somers 382fae26bdSAlan Somers fill_fs $TESTDIR -1 $FILE_COUNT $BLOCKSZ $WRITE_COUNT 392fae26bdSAlan Somers while [ "$atfile" -lt "$FILE_COUNT" ]; do 402fae26bdSAlan Somers if [ -f ${TESTDIR}/0/${TESTFILE}.${atfile} ]; then 412fae26bdSAlan Somers cksums[$atfile]=$($CKSUM ${TESTDIR}/0/${TESTFILE}.${atfile}) 422fae26bdSAlan Somers fi 432fae26bdSAlan Somers (( atfile = $atfile + 1 )) 442fae26bdSAlan Somers done 452fae26bdSAlan Somers 462fae26bdSAlan Somers # unmount and export before dd 472fae26bdSAlan Somers log_must $ZPOOL export $POOL 482fae26bdSAlan Somers 492fae26bdSAlan Somers # dd the affected side of the mirror 502fae26bdSAlan Somers log_must $DD if=$OVERWRITING_DEVICE of=$(bsddevmap $AFFECTED_DEVICE) \ 512fae26bdSAlan Somers seek=8 bs=$BLOCKSZ count=$(( WRITE_COUNT - 8 )) conv=notrunc 522fae26bdSAlan Somers 532fae26bdSAlan Somers # now remount and scrub 542fae26bdSAlan Somers log_must $ZPOOL import $POOL 552fae26bdSAlan Somers log_must $ZPOOL scrub $POOL 562fae26bdSAlan Somers wait_for 60 1 is_pool_scrubbed $POOL 572fae26bdSAlan Somers 582fae26bdSAlan Somers atfile=0 592fae26bdSAlan Somers typeset -i failedcount=0 602fae26bdSAlan Somers while [ "$atfile" -lt "$FILE_COUNT" ]; do 612fae26bdSAlan Somers if [ -f ${TESTDIR}/0/${TESTFILE}.${atfile} ]; then 622fae26bdSAlan Somers newcksum=$($CKSUM $TESTDIR/0/${TESTFILE}.${atfile}) 632fae26bdSAlan Somers if [[ $newcksum != ${cksums[$atfile]} ]]; then 642fae26bdSAlan Somers (( failedcount = $failedcount + 1 )) 652fae26bdSAlan Somers else 662fae26bdSAlan Somers log_note "${TESTFILE}.${atfile} checksums match:"\ 672fae26bdSAlan Somers "old ${cksums[$atfile]} new $newcksum" 682fae26bdSAlan Somers fi 692fae26bdSAlan Somers $RM -f ${files[$atfile]} 702fae26bdSAlan Somers fi 712fae26bdSAlan Somers (( atfile = $atfile + 1 )) 722fae26bdSAlan Somers done 732fae26bdSAlan Somers 742fae26bdSAlan Somers if [ "$failedcount" -gt 0 ]; then 752fae26bdSAlan Somers log_fail "of the $FILE_COUNT files $failedcount did not " \ 762fae26bdSAlan Somers "have the same checksum before and after." 772fae26bdSAlan Somers fi 782fae26bdSAlan Somers} 79