wok rev 19838

syslinux/iso2exe: fix hybrid mbr read
author Pascal Bellard <pascal.bellard@slitaz.org>
date Sun Mar 12 09:47:07 2017 +0100 (2017-03-12)
parents 658ada1dde7e
children 8211a9c470d6
files syslinux/stuff/iso2exe/iso2exe.sh
line diff
     1.1 --- a/syslinux/stuff/iso2exe/iso2exe.sh	Sat Mar 11 11:56:27 2017 +0100
     1.2 +++ b/syslinux/stuff/iso2exe/iso2exe.sh	Sun Mar 12 09:47:07 2017 +0100
     1.3 @@ -264,17 +264,22 @@
     1.4  	fi
     1.5  }
     1.6  
     1.7 +restore_hybrid_mbr()
     1.8 +{
     1.9 +	if [ $(get 0 "$1") -eq 60905 ]; then
    1.10 +		ddq bs=1 conv=notrunc if="$1" of="$1" skip=$((0x1BE)) seek=0 count=3
    1.11 +		ddq bs=1 skip=$((0x1BE)) count=66 if="$2" | \
    1.12 +			ddq bs=1 seek=$((0x1BE)) count=66 of="$1" conv=notrunc
    1.13 +	fi
    1.14 +}
    1.15 +
    1.16  extract()
    1.17  {
    1.18  	for f in $@; do
    1.19  		fileofs $f
    1.20  		[ $SIZE -eq 0 ] ||
    1.21  		ddq bs=1 count=$SIZE skip=$OFFSET if="$ISO" >$f
    1.22 -		if [ "$f" == "syslinux.mbr" ] && [ $(get 0 "$f") -eq 60905 ]; then
    1.23 -			ddq bs=1 conv=notrunc if="$f" of="$f" skip=$((0x1BE)) seek=0 count=3
    1.24 -			ddq bs=1 skip=$((0x1BE)) count=66 if="$ISO" | \
    1.25 -				ddq bs=1 seek=$((0x1BE)) count=66 of="$f" conv=notrunc
    1.26 -		fi
    1.27 +		[ "$f" == "syslinux.mbr" ] && restore_hybrid_mbr "$f" "$ISO"
    1.28  	done
    1.29  }
    1.30  
    1.31 @@ -508,7 +513,10 @@
    1.32  	    23117)
    1.33  		b=$(get 417 $1 1)
    1.34  		n=$(($(get 64 $1) + 0xC0 - ($(get 26 $1 1)*512) - ($b+1)*512))
    1.35 -		ddq if=$1 bs=512 count=1 skip=$b of=$1 conv=notrunc
    1.36 +		ddq if=$1 bs=512 count=1 skip=$b of=/tmp/hymbr$$
    1.37 +		restore_hybrid_mbr /tmp/hymbr$$ $1
    1.38 +		ddq if=/tmp/hymbr$$ of=$1 conv=notrunc
    1.39 +		rm -f /tmp/hymbr$$
    1.40  		if [ $(get 512 $1) -eq 17989 ]; then
    1.41  			n=$(($(get 0x25C $1)/512))
    1.42  			ddq if=$1 bs=512 seek=44 count=20 skip=$n of=$1 conv=notrunc