#!/bin/ksh # # CDDL HEADER START # # The contents of this file are subject to the terms of the # Common Development and Distribution License (the "License"). # You may not use this file except in compliance with the License. # # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE # or http://www.opensolaris.org/os/licensing. # See the License for the specific language governing permissions # and limitations under the License. # # When distributing Covered Code, include this CDDL HEADER in each # file and include the License file at usr/src/OPENSOLARIS.LICENSE. # If applicable, add the following below this CDDL HEADER, with the # fields enclosed by brackets "[]" replaced with your own identifying # information: Portions Copyright [yyyy] [name of copyright owner] # # CDDL HEADER END # # # Copyright 2007 Sun Microsystems, Inc. All rights reserved. # Use is subject to license terms. # # defaults setvar bblen = '7680' setvar rdlen = '256' setvar totlen = '7680' while getopts b:r:e: a { match $a { with b setvar bblen = "$OPTARG" with r setvar rdlen = "$OPTARG" with e setvar extra = "$OPTARG" setvar totlen = '15872' with ? printf "Usage: %s: [ -b bb_len ] [ -r rd_len ] boot_fcode ramdisk_fcode bootblk\n" $0 exit -1 } } shift $(($OPTIND - 1)) # # check boot code and ramdisk code for size overflow # setvar rdoff = $(($bblen - $rdlen)) setvar bbsize = $(ls -l $1 | awk -e '{ print $5 }') if test $bbsize -gt $rdoff { printf "$1 must be smaller than $rdoff\n" exit -1 } setvar rdsize = $(ls -l $2 | awk -e '{ print $5 }') if test $rdsize -gt $rdlen { printf "$1 must be smaller than $rdlen\n" exit -1 } # # make the bootblk # mkfile -n $totlen $3 chmod 644 $3 dd if=$1 of=$3 conv=notrunc bs=1 dd if=$2 of=$3 conv=notrunc bs=1 oseek=$rdoff # # extended bootblk for zfs debug # if test $totlen -gt $bblen { setvar extsize = $(ls -l $extra | awk -e '{ print $5 }') if test $extsize -gt 16384 { printf "$1 must be smaller than 16k\n" exit -1 } dd if=$extra of=$3 conv=notrunc bs=1 oseek=$bblen } exit 0