From 65cdb2eaabadc7ba9dfe499bc208672a947e3b98 Mon Sep 17 00:00:00 2001 From: hpa Date: Thu, 27 Nov 2003 05:36:16 +0000 Subject: [PATCH] Add "onerror" configuration directive --- NEWS | 5 ++++- isolinux.asm | 2 ++ keywords | 1 + keywords.inc | 1 + ldlinux.asm | 2 ++ parseconfig.inc | 14 +++++++++++--- pxelinux.asm | 2 ++ syslinux.doc | 17 +++++++++++++++++ ui.inc | 46 ++++++++++++++++++++++++++++++++++++++++------ 9 files changed, 80 insertions(+), 10 deletions(-) diff --git a/NEWS b/NEWS index 7c76e87..ec26f7d 100644 --- a/NEWS +++ b/NEWS @@ -5,6 +5,8 @@ them. Changes in 2.08: * Add new configuration command "ontimeout" to allow timeout to have a different action than just pressing Enter. + * Add new configuration command "onerror" to allow a custom + command to be executed in case the kernel image is not found. * Fix bugs in the COMBOOT/COM32 command-line parsing. APPEND now works with COMBOOT/COM32 images. * PXELINUX: Poll for ARP requests while sitting at the @@ -15,7 +17,8 @@ Changes in 2.08: * MEMDISK: Add an API to query for the existence of MEMDISK. * SYSLINUX: Fix loading boot sectors (.bs/.bss) from floppy disk. - * .c32 is now one of the extensions searched for automatically. + * .c32 is now one of the extensions searched for + automatically. Changes in 2.07: * MEMDISK: Workaround for BIOSes which go into a snit when diff --git a/isolinux.asm b/isolinux.asm index 57488cb..fd67d2e 100644 --- a/isolinux.asm +++ b/isolinux.asm @@ -134,6 +134,7 @@ VKernelBuf: resb vk_size ; "Current" vkernel alignb 4 AppendBuf resb max_cmd_len+1 ; append= Ontimeout resb max_cmd_len+1 ; ontimeout +Onerror resb max_cmd_len+1 ; onerror KbdMap resb 256 ; Keyboard map FKeyName resb 10*FILENAME_MAX ; File names for F-key help NumBuf resb 15 ; Buffer to load number @@ -1614,6 +1615,7 @@ img_table: ; AppendLen dw 0 ; Bytes in append= command OntimeoutLen dw 0 ; Bytes in ontimeout command +OnerrorLen dw 0 ; Bytes in onerror command KbdTimeOut dw 0 ; Keyboard timeout (if any) CmdLinePtr dw cmd_line_here ; Command line advancing pointer initrd_flag equ $ diff --git a/keywords b/keywords index 4e55f15..28efdbc 100644 --- a/keywords +++ b/keywords @@ -14,6 +14,7 @@ say serial timeout ontimeout +onerror f0 f1 f2 diff --git a/keywords.inc b/keywords.inc index 2fcae3b..7496dab 100644 --- a/keywords.inc +++ b/keywords.inc @@ -58,6 +58,7 @@ keywd_table: keyword serial, pc_serial keyword timeout, pc_timeout keyword ontimeout, pc_ontimeout + keyword onerror, pc_onerror keyword f1, pc_fkey, FKeyName+(0< to boot. +ONERROR kernel options... + If a kernel image is not found (either due to it not existing, + or because IMPLICIT is set), run the specified command. The + faulty command line is appended to the specified options, so + if the ONERROR directive reads as: + + ONERROR xyzzy plugh + + ... and the command line as entered by the user is: + + foo bar baz + + ... SYSLINUX will execute the following as if entered by the + user: + + xyzzy plugh foo bar baz + SERIAL port [[baudrate] flowcontrol] Enables a serial port to act as the console. "port" is a number (0 = /dev/ttyS0 = COM1, etc.) or an I/O port address diff --git a/ui.inc b/ui.inc index 8688c32..c11c088 100644 --- a/ui.inc +++ b/ui.inc @@ -276,7 +276,17 @@ get_kernel: mov byte [KernelName+FILENAME_MAX],0 ; Zero-terminate filename/e add bx,byte 4 cmp bx,exten_table_end jna .search_loop ; allow == case (final case) -bad_kernel: + ; Fall into bad_kernel +; +; bad_kernel: Kernel image not found +; bad_implicit: The user entered a nonvirtual kernel name, with "implicit 0" +; +bad_implicit: +bad_kernel: + mov cx,[OnerrorLen] + and cx,cx + jnz on_error +.really: mov si,KernelName mov di,KernelCName push di @@ -287,13 +297,37 @@ bad_kernel: call cwritestr mov si,crlf_msg jmp abort_load ; Ask user for clue + ; -; bad_implicit: The user entered a nonvirtual kernel name, with "implicit 0" +; on_error: bad kernel, but we have onerror set ; -bad_implicit: mov si,KernelName ; For the error message - mov di,KernelCName - call unmangle_name - jmp short bad_kernel +on_error: + mov si,Onerror + mov di,command_line + push si ; + push di ; + push cx ; + push cx ; + push di ; + repe cmpsb + pop di ; di == command_line + pop bx ; bx == [OnerrorLen] + je bad_kernel.really ; Onerror matches command_line already + neg bx ; bx == -[OnerrorLen] + lea cx,[max_cmd_len+bx] + ; CX == max_cmd_len-[OnerrorLen] + mov di,command_line+max_cmd_len-1 + mov byte [di+1],0 ; Enforce null-termination + lea si,[di+bx] + std + rep movsb ; Make space in command_line + cld + pop cx ; cx == [OnerrorLen] + pop di ; di == command_line + pop si ; si == Onerror + rep movsb + jmp load_kernel + ; ; vk_found: We *are* using a "virtual kernel" ; -- 2.7.4