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. $STF_SUITE/include/libtest.kshlib 28 29# 30# Create block file or charactor file according to parameter. 31# 32# $1 device file type 33# $2 file name 34# 35function create_dev_file 36{ 37 typeset filetype=$1 38 typeset filename=$2 39 40 case $filetype in 41 b) 42 devtype=$($DF -T / | $AWK '{print $2}') 43 case $devtype in 44 zfs) 45 rootpool=$($DF / | \ 46 $AWK '{print $2}') 47 rootpool=${rootpool#\(} 48 rootpool=${rootpool%%/*} 49 50 devstr=$(get_disklist $rootpool) 51 devstr=$($ECHO "$devstr" | \ 52 $AWK '{print $1}') 53 [[ -z $devstr ]] && \ 54 log_fail "Can not get block device file." 55 devstr=/dev/${devstr} 56 ;; 57 ufs) 58 # 59 # Get the existing block device file in current system. 60 # And bring out the first one. 61 # 62 devstr=$($DF -lht ufs | \ 63 $GREP "^/dev/" | \ 64 $AWK '{print $1}') 65 devstr=$($ECHO "$devstr" | \ 66 $AWK '{print $1}') 67 [[ -z $devstr ]] && \ 68 log_fail "Can not get block device file." 69 ;; 70 *) 71 log_unsupported "Unsupported fstype " \ 72 "for / ($devtype)," \ 73 "only ufs|zfs is supported." 74 ;; 75 esac 76 77 # 78 # Get the device file information. i.e: 79 # /dev/c0t0d0s0: block special (28/768) 80 # 81 devstr=$($FILE $devstr) 82 83 # 84 # Bring out major and minor number. 85 # 86 major=${devstr##*\(} 87 major=${major%%/*} 88 minor=${devstr##*/} 89 minor=${minor%\)} 90 91 log_must $MKNOD $filename b $major $minor 92 ;; 93 c) 94 # 95 # Create device file '/dev/null' 96 # 97 log_must $MKNOD $filename c 13 2 98 ;; 99 *) 100 log_fail "'$filetype' is wrong." 101 ;; 102 esac 103 104 return 0 105} 106 107function cleanup 108{ 109 log_must $ZFS set devices=on $TESTPOOL/$TESTFS 110 log_must $RM -f $TESTDIR/$TESTFILE1 111 log_must $RM -f $TESTDIR/$TESTFILE2 112 log_must $RM -f $TESTDIR/$TESTFILE1.out 113 log_must $RM -f $TESTDIR/$TESTFILE2.out 114} 115 116