1*5648Ssetje#!/bin/ksh 2*5648Ssetje# 3*5648Ssetje# CDDL HEADER START 4*5648Ssetje# 5*5648Ssetje# The contents of this file are subject to the terms of the 6*5648Ssetje# Common Development and Distribution License (the "License"). 7*5648Ssetje# You may not use this file except in compliance with the License. 8*5648Ssetje# 9*5648Ssetje# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10*5648Ssetje# or http://www.opensolaris.org/os/licensing. 11*5648Ssetje# See the License for the specific language governing permissions 12*5648Ssetje# and limitations under the License. 13*5648Ssetje# 14*5648Ssetje# When distributing Covered Code, include this CDDL HEADER in each 15*5648Ssetje# file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16*5648Ssetje# If applicable, add the following below this CDDL HEADER, with the 17*5648Ssetje# fields enclosed by brackets "[]" replaced with your own identifying 18*5648Ssetje# information: Portions Copyright [yyyy] [name of copyright owner] 19*5648Ssetje# 20*5648Ssetje# CDDL HEADER END 21*5648Ssetje# 22*5648Ssetje# 23*5648Ssetje# Copyright 2007 Sun Microsystems, Inc. All rights reserved. 24*5648Ssetje# Use is subject to license terms. 25*5648Ssetje# 26*5648Ssetje#ident "%Z%%M% %I% %E% SMI" 27*5648Ssetje# 28*5648Ssetje 29*5648Ssetje#!/bin/sh 30*5648Ssetje 31*5648Ssetje# defaults 32*5648Ssetjebblen=7680 33*5648Ssetjerdlen=256 34*5648Ssetjetotlen=7680 35*5648Ssetje 36*5648Ssetjewhile getopts b:r:e: a; do 37*5648Ssetje case $a in 38*5648Ssetje b) bblen=$OPTARG;; 39*5648Ssetje r) rdlen=$OPTARG;; 40*5648Ssetje e) extra=$OPTARG 41*5648Ssetje totlen=15872;; 42*5648Ssetje ?) printf "Usage: %s: [ -b bb_len ] [ -r rd_len ] boot_fcode ramdisk_fcode bootblk\n" $0 43*5648Ssetje exit -1;; 44*5648Ssetje esac 45*5648Ssetjedone 46*5648Ssetjeshift $(($OPTIND - 1)) 47*5648Ssetje 48*5648Ssetje# 49*5648Ssetje# check boot code and ramdisk code for size overflow 50*5648Ssetje# 51*5648Ssetjerdoff=$(($bblen - $rdlen)) 52*5648Ssetje 53*5648Ssetjebbsize=$(ls -l $1 | awk -e '{ print $5 }') 54*5648Ssetjeif [ $bbsize -gt $rdoff ]; then 55*5648Ssetje printf "$1 must be smaller than $rdoff\n" 56*5648Ssetje exit -1 57*5648Ssetjefi 58*5648Ssetje 59*5648Ssetjerdsize=$(ls -l $2 | awk -e '{ print $5 }') 60*5648Ssetjeif [ $rdsize -gt $rdlen ]; then 61*5648Ssetje printf "$1 must be smaller than $rdlen\n" 62*5648Ssetje exit -1 63*5648Ssetjefi 64*5648Ssetje 65*5648Ssetje# 66*5648Ssetje# make the bootblk 67*5648Ssetje# 68*5648Ssetjemkfile -n $totlen $3 69*5648Ssetjechmod 644 $3 70*5648Ssetjedd if=$1 of=$3 conv=notrunc bs=1 71*5648Ssetjedd if=$2 of=$3 conv=notrunc bs=1 oseek=$rdoff 72*5648Ssetje 73*5648Ssetje# 74*5648Ssetje# extended bootblk for zfs debug 75*5648Ssetje# 76*5648Ssetjeif [ $totlen -gt $bblen ]; then 77*5648Ssetje extsize=$(ls -l $extra | awk -e '{ print $5 }') 78*5648Ssetje if [ $extsize -gt 8192 ]; then 79*5648Ssetje printf "$1 must be smaller than 8k\n" 80*5648Ssetje exit -1 81*5648Ssetje fi 82*5648Ssetje dd if=$extra of=$3 conv=notrunc bs=1 oseek=$bblen 83*5648Ssetjefi 84*5648Ssetje 85*5648Ssetjeexit 0 86