NetBSD/sys/arch/x68k/stand/writefdboot

31 lines
609 B
Bash

#!/bin/sh
#
# do like as disklabel -B
# --written by Yasha
#
# usage: writeboot <boot_file> <boot_device(raw)>
#
case "$#" in
2) ;;
*) echo "usage: `basename $0` fdboot /dev/rfd?a" >&2
exit 1;;
esac
boot="$1"
rootdev="$2"
temp=/tmp/writeboot$$
set - `ls -lLd "$boot"`
case "$5" in [1-9]*) :;; *) exit 1;; esac
nblock=`expr \( $5 + 1023 \) / 1024 `
trap "rm -f $temp; exit 1" 1 2 3 15
rm -f $temp
( dd if="$boot" bs=64 count=1
dd if="$rootdev" bs=1024 count=1 | dd bs=4 skip=16 count=69
dd if="$boot" bs=340 skip=1 ) > $temp
cat $temp /dev/zero | dd bs=1024 count=$nblock of="$rootdev"
rm -f $temp