6041 SPARC boot should support LZ4
[unleashed.git] / usr / src / psm / stand / bootblks / common / mkbb.sh
blob115126ed1e471847fc5363c012504ab2de21dcbc
1 #!/bin/ksh
3 # CDDL HEADER START
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.
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.
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]
20 # CDDL HEADER END
23 # Copyright 2007 Sun Microsystems, Inc. All rights reserved.
24 # Use is subject to license terms.
27 # defaults
28 bblen=7680
29 rdlen=256
30 totlen=7680
32 while getopts b:r:e: a; do
33 case $a in
34 b) bblen=$OPTARG;;
35 r) rdlen=$OPTARG;;
36 e) extra=$OPTARG
37 totlen=15872;;
38 ?) printf "Usage: %s: [ -b bb_len ] [ -r rd_len ] boot_fcode ramdisk_fcode bootblk\n" $0
39 exit -1;;
40 esac
41 done
42 shift $(($OPTIND - 1))
45 # check boot code and ramdisk code for size overflow
47 rdoff=$(($bblen - $rdlen))
49 bbsize=$(ls -l $1 | awk -e '{ print $5 }')
50 if [ $bbsize -gt $rdoff ]; then
51 printf "$1 must be smaller than $rdoff\n"
52 exit -1
55 rdsize=$(ls -l $2 | awk -e '{ print $5 }')
56 if [ $rdsize -gt $rdlen ]; then
57 printf "$1 must be smaller than $rdlen\n"
58 exit -1
62 # make the bootblk
64 mkfile -n $totlen $3
65 chmod 644 $3
66 dd if=$1 of=$3 conv=notrunc bs=1
67 dd if=$2 of=$3 conv=notrunc bs=1 oseek=$rdoff
70 # extended bootblk for zfs debug
72 if [ $totlen -gt $bblen ]; then
73 extsize=$(ls -l $extra | awk -e '{ print $5 }')
74 if [ $extsize -gt 16384 ]; then
75 printf "$1 must be smaller than 16k\n"
76 exit -1
78 dd if=$extra of=$3 conv=notrunc bs=1 oseek=$bblen
81 exit 0