wok-current diff linux/stuff/bootloader.sh @ rev 13797

Create grub entry based on current root partition. Fix bug78
author border
date Sat Jan 05 12:34:10 2013 -0500 (2013-01-05)
parents cae46feb2397
children 1ed0f1f453b3
line diff
     1.1 --- a/linux/stuff/bootloader.sh	Mon Jul 30 10:59:32 2012 +0200
     1.2 +++ b/linux/stuff/bootloader.sh	Sat Jan 05 12:34:10 2013 -0500
     1.3 @@ -88,10 +88,10 @@
     1.4  	[ -n "$DEBUG" ] && printf "store%d(%03X) = %0$(($1/4))X	%s\n" $1 $2 $3 "$5" 1>&2
     1.5  }
     1.6  
     1.7 -# usage: getlong offset file
     1.8 +# usage: getlong offset file [bytes]
     1.9  getlong()
    1.10  {
    1.11 -	ddq if=$2 bs=1 skip=$(($1)) count=4 | hexdump -e '"" 1/4 "%d" "\n"'
    1.12 +	od -j $1 -N ${3:-4} -t u${3:-4} -An $2
    1.13  }
    1.14  
    1.15  error()
    1.16 @@ -122,8 +122,7 @@
    1.17  	[ -n "$DEBUG" ] && echo "Read bootsector..." 1>&2
    1.18  	ddq if=$KERNEL bs=512 count=1 of=$bs
    1.19  
    1.20 -	[ $(( $(getlong 0x1FE $bs) & 0xFFFF )) -eq 43605 ] ||
    1.21 -		error "Not bootable"
    1.22 +	[ $(getlong 0x1FE $bs 2) -eq 43605 ] || error "Not bootable"
    1.23  	
    1.24  	uudecode <<EOT | ddq of=$bs conv=notrunc
    1.25  begin-base64 644 -
    1.26 @@ -141,7 +140,7 @@
    1.27  ====
    1.28  EOT
    1.29  	# Get setup
    1.30 -	setupsz=$(( $(getlong $SetupSzOfs $bs) & 0xFF ))
    1.31 +	setupsz=$(getlong $SetupSzOfs $bs 1)
    1.32  	if [ $setupsz -eq 0 ]; then
    1.33  		setupsz=4
    1.34  		store 8 $SetupSzOfs $setupsz $bs "setup size $setupsz"
    1.35 @@ -149,7 +148,7 @@
    1.36  	[ -n "$DEBUG" ] && echo "Read setup ($setupsz sectors) ..." 1>&2
    1.37  	ddq if=$KERNEL bs=512 skip=1 count=$setupsz >> $bs
    1.38  
    1.39 -	Version=$(( $(getlong 0x206 $bs) & 0xFFFF ))
    1.40 +	Version=$(getlong 0x206 $bs 2)
    1.41  	[ $(getlong $Magic $bs) -ne 1400005704 ] && Version=0
    1.42  	feature=""
    1.43  	while read prot kern info ; do
    1.44 @@ -181,7 +180,7 @@
    1.45  201 FFF 224	00:9B				heap_end_ptr
    1.46  EOT
    1.47  	if [ $Version -lt 514 ]; then
    1.48 -		version_string=$((0x200 + ($(getlong 0x20E $bs) & 65535) ))
    1.49 +		version_string=$((0x200 + $(getlong 0x20E $bs 2) ))
    1.50  		store	16	0x0037	$version_string	$bs version_string
    1.51  	fi
    1.52  	if [ $Version -ge 512 -a $(getlong 0x214 $bs) -ge $((0x100000)) ]; then