Gene Cumm
2008-Nov-10 00:22 UTC
[syslinux] [PATCH 1/1] COMBOOT API: Add get current working directory call to most
From: Gene Cumm <gene.cumm at gmail.com> COMBOOT API: Add get current working directory call to most Signed-off-by: Gene Cumm <gene.cumm at gmail.com> --- Adds an API call to obtain the current working directory. EXTLINUX will not return the correct value yet however SYSLINUX, ISOLINUX, and PXELINUX will return the correct value. For the moment, EXTLINUX will ONLY return "/" (null-terminated of course). In SYSLINUX and ISOLINUX, it presets the CurrentDirName string to "/" for safety. PXELINUX copies TFTP Prefix to CurrentDirName (minus the trailing "/"). Based on current head. Conflicts with a previous patch I e-mailed. diff --git a/core/comboot.inc b/core/comboot.inc index 810d825..bdc43ba 100644 --- a/core/comboot.inc +++ b/core/comboot.inc @@ -1033,6 +1033,14 @@ comapi_getadv: ; comapi_writeadv equ adv_write +; +; INT 22h AX=001Eh Get current working directory +; +comapi_getcwd mov P_ES,cs + mov P_BX,CurrentDirName + clc + ret + section .data %macro int21 2 @@ -1085,6 +1093,7 @@ int22_table: dw comapi_shufflerm ; 001B cleanup, shuffle and boot to rm dw comapi_getadv ; 001C get pointer to ADV dw comapi_writeadv ; 001D write ADV to disk + dw comapi_getcwd ; 001E get current working directory int22_count equ ($-int22_table)/2 APIKeyWait db 0 @@ -1109,3 +1118,4 @@ err_comlarge db 'COMBOOT image too large.', CR, LF, 0 alignb 4 DOSErrTramp resd 33 ; Error trampolines ConfigName resb FILENAME_MAX +CurrentDirName resb FILENAME_MAX diff --git a/core/extlinux.asm b/core/extlinux.asm index 24d0d92..c9ec166 100644 --- a/core/extlinux.asm +++ b/core/extlinux.asm @@ -42,6 +42,8 @@ MAX_SYMLINKS equ 64 ; Maximum number of symlinks per lookup SYMLINK_SECTORS equ 2 ; Max number of sectors in a symlink ; (should be >= FILENAME_MAX) +ROOT_DIR_WORD equ 0x002F + ; ; This is what we need to do when idle ; @@ -843,6 +845,8 @@ load_config: mov si,config_name ; Save config file name mov di,ConfigName call strcpy + mov word[CurrentDirName], ROOT_DIR_WORD ; Write '/',0 to the CurrentDirName + call build_curdir_str mov di,ConfigName call open @@ -1515,6 +1519,9 @@ getfssec: pop ebp ret +build_curdir_str: + ret + ; ----------------------------------------------------------------------------- ; Common modules ; ----------------------------------------------------------------------------- diff --git a/core/isolinux.asm b/core/isolinux.asm index 3b97005..fbd1ba0 100644 --- a/core/isolinux.asm +++ b/core/isolinux.asm @@ -36,6 +36,8 @@ MAX_OPEN equ (1 << MAX_OPEN_LG2) SECTOR_SHIFT equ 11 ; 2048 bytes/sector (El Torito requirement) SECTOR_SIZE equ (1 << SECTOR_SHIFT) +ROOT_DIR_WORD equ 0x002F + ; ; This is what we need to do when idle ; @@ -1147,15 +1149,30 @@ get_fs_structures: ; Look for an isolinux directory, and if found, ; make it the current directory instead of the root ; directory. + ; Also copy the name of the directory to CurrentDirName + mov word[CurrentDirName], ROOT_DIR_WORD ; Write '/',0 to the CurrentDirName mov di,boot_dir ; Search for /boot/isolinux mov al,02h + push di call searchdir_iso + pop di jnz .found_dir mov di,isolinux_dir mov al,02h ; Search for /isolinux + push di call searchdir_iso + pop di jz .no_isolinux_dir .found_dir: + ; Copy current directory name to CurrentDirName + push si + push di + mov si,di + mov di,CurrentDirName + call strcpy + pop di + pop si + mov [CurrentDir+dir_len],eax mov eax,[si+file_left] mov [CurrentDir+dir_clust],eax diff --git a/core/ldlinux.asm b/core/ldlinux.asm index c7f6577..75e8fef 100644 --- a/core/ldlinux.asm +++ b/core/ldlinux.asm @@ -44,6 +44,8 @@ MAX_OPEN equ (1 << MAX_OPEN_LG2) SECTOR_SHIFT equ 9 SECTOR_SIZE equ (1 << SECTOR_SHIFT) +ROOT_DIR_WORD equ 0x002F + ; ; This is what we need to do when idle ; @@ -900,19 +902,40 @@ getfattype: mov si,config_name ; Save configuration file name mov di,ConfigName call strcpy + mov word[CurrentDirName], ROOT_DIR_WORD ; Write '/',0 to the CurrentDirName mov eax,[RootDir] ; Make the root directory ... mov [CurrentDir],eax ; ... the current directory mov di,syslinux_cfg1 + push di call open + pop di jnz .config_open mov di,syslinux_cfg2 + push di call open + pop di jnz .config_open mov di,syslinux_cfg3 + push di call open + pop di jz no_config_file .config_open: + push si + mov si,di + push si + mov di,CurrentDirName + ; This is inefficient as it will copy more than needed + ; but not by too much + call strcpy + mov ax,syslinux_cfg3 ;Cut it down + pop si + sub ax,si + mov di,CurrentDirName + add di,ax + mov byte[di],0 + pop si mov eax,[PrevDir] ; Make the directory with syslinux.cfg ... mov [CurrentDir],eax ; ... the current directory diff --git a/core/pxelinux.asm b/core/pxelinux.asm index 4398582..95c5bee 100644 --- a/core/pxelinux.asm +++ b/core/pxelinux.asm @@ -704,6 +704,15 @@ prefix: test byte [DHCPMagic], 04h ; Did we get a path prefix option call writestr_early call crlf + ; Set CurrentDirName + push di + mov si,PathPrefix + mov di,CurrentDirName + call strcpy + sub di,2 + mov byte[di],0 + pop di + ; ; Load configuration file ;
H. Peter Anvin
2008-Nov-10 00:40 UTC
[syslinux] [PATCH 1/1] COMBOOT API: Add get current working directory call to most
Gene Cumm wrote:> From: Gene Cumm <gene.cumm at gmail.com> > > COMBOOT API: Add get current working directory call to most > > Signed-off-by: Gene Cumm <gene.cumm at gmail.com> > > --- > > Adds an API call to obtain the current working directory. EXTLINUX > will not return the correct value yet however SYSLINUX, ISOLINUX, and > PXELINUX will return the correct value. For the moment, EXTLINUX will > ONLY return "/" (null-terminated of course). In SYSLINUX and > ISOLINUX, it presets the CurrentDirName string to "/" for safety. > PXELINUX copies TFTP Prefix to CurrentDirName (minus the trailing > "/"). >Okay, this isn't quite right, especially in the case of the TFTP prefix; the TFTP prefix may not end in '/', especially when the TFTP server is not a Unix system. Therefore I think this call should return a prefix (including a final '/' in case of the filesystem-based variants.) -hpa
Gene Cumm
2008-Nov-10 00:44 UTC
[syslinux] [PATCH 1/1] COMBOOT API: Add get current working directory call to most
On Sun, Nov 9, 2008 at 7:22 PM, Gene Cumm <gene.cumm at gmail.com> wrote:> From: Gene Cumm <gene.cumm at gmail.com> > > COMBOOT API: Add get current working directory call to most > > Signed-off-by: Gene Cumm <gene.cumm at gmail.com> > > --- > > Adds an API call to obtain the current working directory. EXTLINUX > will not return the correct value yet however SYSLINUX, ISOLINUX, and > PXELINUX will return the correct value. For the moment, EXTLINUX will > ONLY return "/" (null-terminated of course). In SYSLINUX and > ISOLINUX, it presets the CurrentDirName string to "/" for safety. > PXELINUX copies TFTP Prefix to CurrentDirName (minus the trailing > "/"). > > Based on current head. Conflicts with a previous patch I e-mailed.Completing the implementation within EXTLINUX will require examining how to recurse up a directory tree, obtaining the name of each directory and then return building the current directory string. It might have been possible to cheat and let the installer pre-populate it (like the INODE number is stored) however moving the directory containing extlinux.sys to become another path (ie from /boot/extlinux to /extlinux) won't change the INODE number (at least the one time I tested) but would invalidate the original stored path.
Seemingly Similar Threads
- [PATCH 1/1] COMBOOT API: Add calls for directory functions; Implement for FAT
- [PATCH 1/1] COMBOOT API: Add calls for directory functions; Implement for FAT; Try 2
- [PATCH 1/1] COMBOOT API: Add get current working directory call to most (revised)
- [PATCH 1/1] COMBOOT: add get config file full name
- [PATCH] mboot using module path