1#!/bin/ksh -p 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 (c) 2023 by iXsystems, Inc. 25# 26 27. $STF_SUITE/include/libtest.shlib 28 29# 30# DESCRIPTION: 31# Negative for FreeBSD Only 32# 33# Attempting to expand a RAIDZ should fail if the scratch area on the 34# existing disks contains BTX Server binary (used to boot FreeBSD when 35# using MBR partitions with ZFS). 36# 37# STRATEGY: 38# 1. Create raidz pool 39# 2. Add a BTX header to the reserved boot area 40# 3. Attempt to attach a device to the raidz vdev 41# 4. Verify that device attached failed 42# 5. Destroy the raidz pool 43 44typeset -r devs=4 45typeset -r dev_size_mb=128 46typeset -a disks 47 48function cleanup 49{ 50 log_pos zpool status "$TESTPOOL" 51 52 poolexists "$TESTPOOL" && log_must_busy zpool destroy "$TESTPOOL" 53 54 for i in {0..$devs}; do 55 log_must rm -f "$TEST_BASE_DIR/dev-$i" 56 done 57} 58 59log_onexit cleanup 60 61for i in {0..$devs}; do 62 device=$TEST_BASE_DIR/dev-$i 63 # simulate active BTX Server data by inserting a BTX header 64 printf "\xeb\x0e%s\x01\x02\x80" "BTX" | dd of="$device" \ 65 bs=512 seek=1024 status=none 66 log_must truncate -s ${dev_size_mb}M "$device" 67 if [[ $i -ne $devs ]]; then 68 disks[${#disks[*]}+1]=$device 69 fi 70done 71 72log_must zpool create -f -o cachefile=none "$TESTPOOL" raidz1 "${disks[@]}" 73 74if is_freebsd; then 75 # expecting attach to fail 76 log_mustnot_expect "the reserved boot area" zpool attach -f \ 77 "$TESTPOOL" raidz1-0 "$TEST_BASE_DIR/dev-$devs" 78 log_must zpool destroy "$TESTPOOL" 79 log_pass "raidz attach failed with in-use reserved boot area" 80else 81 # expecting attach to pass everywhere else 82 log_must zpool attach -f "$TESTPOOL" raidz1-0 "$TEST_BASE_DIR/dev-$devs" 83 log_must zpool destroy "$TESTPOOL" 84 log_pass "raidz attach passed with in-use reserved boot area" 85fi 86 87