NetBSD/sys/arch/x68k/stand/writefdboot

32 lines
670 B
Bash

#!/bin/sh
#
# do like as disklabel -B
# --written by Yasha
#
# usage: writeboot <boot_file> <boot_device(raw)>
#
# $NetBSD: writefdboot,v 1.2 1998/01/05 20:52:24 perry Exp $
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