# HG changeset patch # User Pascal Bellard # Date 1423319986 -3600 # Node ID 00bb1e4137c678ecf36d9fb1f866d802b4dba433 # Parent 4460c3cc7f05f83c47cf8f572866940d4b5b51ab syslinux/iso2exe: use iso size to compute md5sum diff -r 4460c3cc7f05 -r 00bb1e4137c6 syslinux/stuff/iso2exe/boot.c --- a/syslinux/stuff/iso2exe/boot.c Fri Feb 06 22:54:07 2015 +0000 +++ b/syslinux/stuff/iso2exe/boot.c Sat Feb 07 15:39:46 2015 +0100 @@ -158,16 +158,7 @@ cmdfile = argv[1] + 1; else { cmdfile = NULL; -#asm - push ds - pop es - mov si, #0x82 - mov di, #_args - mov cx, #0x7E/2 - rep - seg cs - movsw -#endasm + copycmdline(args); } } if (cmdfile) { diff -r 4460c3cc7f05 -r 00bb1e4137c6 syslinux/stuff/iso2exe/bootiso.S --- a/syslinux/stuff/iso2exe/bootiso.S Fri Feb 06 22:54:07 2015 +0000 +++ b/syslinux/stuff/iso2exe/bootiso.S Sat Feb 07 15:39:46 2015 +0100 @@ -119,7 +119,7 @@ jmp halt .org 0x01BE - .org 0x7F10 + .org 0x7F26 ////////////////////////////// DOS EXE code /////////////////////////////////// exestart: @@ -134,14 +134,16 @@ cwd // clear dx pushw %dx // dos exit() je abort + pushw %si int $0x21 // get DOS version - cmpb $3, %al + popw %di // %di = 0x100: .COM start address + addb $-3, %al movb $EXESTR(noDOS3), %al - jb abort + jnc abort movw $(EXELOC(0x8000))/2, %cx chklp: lodsw - addw %ax, %dx + addw %ax, %dx // break C loop chklp chked: movw $0x1000+EXESTR(chkerr), %ax @@ -164,15 +166,11 @@ addb %ah, %bh // test F0 and 00 cases cmpb %ah, %bh movb $EXESTR(no386), %al -#undef NEED386 -#ifdef NEED386 - jbe abort // C=8086/80186, Z=80286 -#else jbe is86 // C=8086/80186, Z=80286 -#endif is386: smsww %ax // not privileged andb $1, %al + movw $10, %si jne tstvcpi movl %cr0, %eax // privileged incl %eax @@ -182,7 +180,6 @@ realmode: is86: call puts - movw $0x0100, %di movw comstart-end_header(%di), %si // .com address pushw %di movb $0x7C/2, %ch // 31K-31.5K, > com length @@ -191,15 +188,13 @@ ret VersionVCPI: - cmpb $0x40, %dl // >= 4.0 ? - jb NoVCPI xchgw %ax, %si // movb $EXESTR(vm86modemsg), %al - jmp realmode + cmpb $0x40, %cl // EMM386 / VCPI 4.0 mini + jnc realmode // %si = 0 tstvcpi: pushw %ds movw %dx, %ds // %dx = 0 movw 0x67*4+2, %ds - movw $10, %si lodsw xorw $0x4D45, %ax // EM(MX) or EM(MQ) lodsw @@ -217,7 +212,7 @@ je VersionVCPI int $0x67 testb %ah, %ah - xchgw %ax, %dx + xchgw %ax, %cx jmp ChkVCPI CmdVCPI: .byte 0x40 // status @@ -227,39 +222,36 @@ vm86modemsg: // --------------- Must be in 7F40 7FFF range ------------------------ - .ascii "vm" // vm86 - .byte EXESTR(_86) + .ascii "vm86" // vm86 mode + .byte EXESTR(mode) ERRvcpi: - .ascii "No VCPI-4.0/EMM" // No VCPI-4.0/EMM386 - .byte EXESTR(_386) -noDOS3: - .ascii "No DOS 3" // No DOS 3 - .byte EXESTR(eol) + .ascii "EMM" // EMM386 need +no386: + .ascii "386" // 386 need + .byte EXESTR(need) chkerr: - .ascii "Broken c" // Broken code + .ascii "Bad c" // Bad code .byte EXESTR(ode) rmPaging: .ascii "Un" // Unreal mode realmodemsg: - .ascii "real m" // real mode + .ascii "real" // real mode // --------------- Must be in 7FC0 7FFF range ------------------------ +mode: + .ascii " m" ode: - .ascii "od" -eeol: - .ascii "e" + .ascii "ode" .byte EXESTR(eol) -no386: - .ascii "No " // No 386 -_386: - .ascii "3" -_86: - .ascii "86" +noDOS3: + .ascii "DOS3" // DOS3 need +need: + .ascii " need" .byte EXESTR(eol) help: - .ascii "SliTaz boot loader" // SliTaz boot loader + .ascii "SliTaz iso boot" // SliTaz iso boot eol: .ascii "\r\n" - .byte 1 + .byte 1 // putstr will return .space 16,0 // ISO md5 .org 0x8000 diff -r 4460c3cc7f05 -r 00bb1e4137c6 syslinux/stuff/iso2exe/init --- a/syslinux/stuff/iso2exe/init Fri Feb 06 22:54:07 2015 +0000 +++ b/syslinux/stuff/iso2exe/init Sat Feb 07 15:39:46 2015 +0100 @@ -70,8 +70,9 @@ done >> /tmp/data while ! grep -q "^$n " /tmp/data ; do clear - [ $(wc -l < /tmp/data) -gt 20 ] && - less /tmp/data || cat /tmp/data + [ $(wc -l < /tmp/data) -gt 22 ] && + sed 's/..3.;4.m/===/g;$aPress q to continue' \ + /tmp/data | less || cat /tmp/data echo -en "\n <- Enter the selection number\r" read n done 2> /dev/null @@ -637,22 +638,24 @@ gotisomd5() { + [ "$(which md5sum 2> /dev/null)" ] && [ $(get 18 /dev/loop0) -ne 0 ] && echo -en "\"$1\" \"$2\"" } isomd5() { dotwait "Checking iso image" - [ "$(ddq if=/dev/loop0 bs=32k skip=1 | md5sum)" == \ + [ "$(ddq if=/dev/loop0 bs=2k skip=16 \ + count=$(echo $(get 32848 /dev/loop0)) | md5sum)" == \ "$(ddq if=/dev/loop0 bs=16 count=1 skip=2047 | od -N 16 -t x1 -An | \ sed 's/ //g') -" ] && echo "OK" || echo "ERROR" - echo -n "Checking iso hybrid boot" + echo -en "\rChecking iso hybrid boot" n=$(($(get 2 /dev/loop0)-1+($(get 4 /dev/loop0)-1)*512)) s=$(get 0 /dev/loop0 2 $n | awk '{ i+= $0 } END { print i }') [ $(((1+$s+$(get $(($n+1)) /dev/loop0 1)) % 65536)) -eq 0 ] && echo "OK" || echo "ERROR" rm -f /tmp/wait - echo "Press RETURN to continue." + echo -e "\rPress RETURN to continue." read n } @@ -746,11 +749,11 @@ $ll $lh $(($n & 0xFFFF)) $(($n >> 16)) | \ ddq bs=1 seek=446 of=$device if [ "$(which mkdosfs 2> /dev/null)" ]; then - losetup -o $((512*$ofs)) /dev/loop0 $device - mkdosfs -n "SLITAZ BOOT" /dev/loop0 + losetup -o $((512*$ofs)) /dev/loop2 $device + mkdosfs -n "SLITAZ BOOT" /dev/loop2 words2bin $(($ofs & 0xFFFF)) $(($ofs >> 16)) | \ - ddq bs=1 seek=28 of=/dev/loop0 - losetup -d /dev/loop0 + ddq bs=1 seek=28 of=/dev/loop2 + losetup -d /dev/loop2 fi fi ; } } @@ -831,7 +834,8 @@ { n=0 dotwait "Extract filesystem..." - for i in $(ls_r /media/cdrom/boot/rootfs*); do + for i in $(ls_r /media/cdrom/boot/rootfs*gz); do + grep -q ' lm ' /proc/cpuinfo && [ -s ${i}64 ] && i=${i}64 [ $((n++)) -eq 0 ] || uncpio $i done rm -f /tmp/wait diff -r 4460c3cc7f05 -r 00bb1e4137c6 syslinux/stuff/iso2exe/iso2exe.sh --- a/syslinux/stuff/iso2exe/iso2exe.sh Fri Feb 06 22:54:07 2015 +0000 +++ b/syslinux/stuff/iso2exe/iso2exe.sh Sat Feb 07 15:39:46 2015 +0100 @@ -205,7 +205,8 @@ *) cat > /dev/null esac - [ ! -s "$1" ] && echo "usage: $0 image.iso [--undo]" 1>&2 && exit 1 + [ ! -s "$1" ] && + echo "usage: $0 image.iso [--undo|\"DOS help message\"]" 1>&2 && exit 1 case "${2/--/-}" in -u*|-r*|-w*) case "$(get 0 $1)" in @@ -237,10 +238,13 @@ add_fdbootstrap $1 printf "%d free bytes in %04X..%04X\n" $(($OFS-$HOLE)) $HOLE $OFS store 26 ${RANDOM:-0} $1 - if [ $(stat -c %s $1) -gt 32768 ]; then - echo "Adding ISO image md5 ..." - echo -en "$(ddq if=$1 bs=32k skip=1 | md5sum | cut -c-32 | sed \ - 's/\(..\)/\\x\1/g')" | ddq bs=16 seek=2047 conv=notrunc of=$1 + [ "$2" ] && echo "$2 " | \ + ddq bs=1 seek=$((0x7FDE)) count=15 conv=notrunc of=$1 + if [ $(stat -c %s $1) -gt 34816 ]; then + echo "Adding ISO image md5 at 7FF0 (16 bytes) ..." + echo -en "$(ddq if=$1 bs=2k skip=16 count=$(get 32848 $1) | \ + md5sum | cut -c-32 | sed 's/\(..\)/\\x\1/g')" | \ + ddq bs=16 seek=2047 conv=notrunc of=$1 fi echo -n "Adding boot checksum..." store 64 $(od -v -j 66 -N 32702 -t u2 -w2 -An $1 | \ diff -r 4460c3cc7f05 -r 00bb1e4137c6 syslinux/stuff/iso2exe/libdos.c --- a/syslinux/stuff/iso2exe/libdos.c Fri Feb 06 22:54:07 2015 +0000 +++ b/syslinux/stuff/iso2exe/libdos.c Sat Feb 07 15:39:46 2015 +0100 @@ -189,3 +189,27 @@ mov _versiondos, ax #endasm } + +void copycmdline(char store[]) +{ +#asm + push si + push di + push ds + pop es + mov si, #0x81 +space: + seg cs + lodsb + cmp al, #0x20 + je space + dec si + mov di, [bp+4] + mov cx, #0x80/2 + rep + seg cs + movsw + pop di + pop si +#endasm +} diff -r 4460c3cc7f05 -r 00bb1e4137c6 syslinux/stuff/iso2exe/libdos.h --- a/syslinux/stuff/iso2exe/libdos.h Fri Feb 06 22:54:07 2015 +0000 +++ b/syslinux/stuff/iso2exe/libdos.h Sat Feb 07 15:39:46 2015 +0100 @@ -9,10 +9,18 @@ extern void dosshutdown(void); extern int versiondos; extern int dosversion(void); +extern void copycmdline(char store[]); # else #define progname() (argv[0]) #define chdirname(x) chdir(dirname(x)) #define dosshutdown() #define dosversion() (0) +#define copycmdline(x) { \ + int n; \ + char *s, *p; \ + for (n = 1, s = x; n < argc; n++, *s++ = ' ') \ + for (p = argv[n]; *p; *s++ = *p++); \ + *s = 0; \ +} # endif #endif