0
|
1 |
#!/bin/sh
|
|
2 |
#
|
|
3 |
# CDDL HEADER START
|
|
4 |
#
|
|
5 |
# The contents of this file are subject to the terms of the
|
6423
|
6 |
# Common Development and Distribution License (the "License").
|
|
7 |
# You may not use this file except in compliance with the License.
|
0
|
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 |
#
|
6423
|
23 |
# Copyright 2008 Sun Microsystems, Inc. All rights reserved.
|
|
24 |
# Use is subject to license terms.
|
0
|
25 |
#
|
|
26 |
#ident "%Z%%M% %I% %E% SMI"
|
|
27 |
#
|
|
28 |
|
|
29 |
away() {
|
|
30 |
echo $2 1>&2
|
|
31 |
exit $1
|
|
32 |
}
|
|
33 |
|
6423
|
34 |
COUNT=15
|
|
35 |
|
|
36 |
while getopts F: a; do
|
|
37 |
case $a in
|
|
38 |
F) case $OPTARG in
|
|
39 |
ufs) COUNT=15;;
|
|
40 |
hsfs) COUNT=15;;
|
|
41 |
zfs) COUNT=31;;
|
|
42 |
*) away 1 "$OPTARG: Unknown fstype";;
|
|
43 |
esac;;
|
|
44 |
?) away 1 "unknows fstype: $fs"
|
|
45 |
esac
|
|
46 |
done
|
|
47 |
shift `expr $OPTIND - 1`
|
|
48 |
|
0
|
49 |
Usage="Usage: `basename $0` bootblk raw-device"
|
|
50 |
|
|
51 |
test $# -ne 2 && away 1 "$Usage"
|
|
52 |
|
|
53 |
BOOTBLK=$1
|
|
54 |
DEVICE=$2
|
|
55 |
test ! -f $BOOTBLK && away 1 "$BOOTBLK: File not found"
|
|
56 |
test ! -c $DEVICE && away 1 "$DEVICE: Not a character device"
|
|
57 |
test ! -w $DEVICE && away 1 "$DEVICE: Not writeable"
|
|
58 |
|
|
59 |
# label at block 0, bootblk from block 1 through 15
|
6423
|
60 |
stderr=`dd if=$BOOTBLK of=$DEVICE bs=1b oseek=1 count=$COUNT conv=sync 2>&1`
|
0
|
61 |
err=$? ; test $err -ne 0 && away $err "$stderr"
|
|
62 |
exit 0
|