Mailing List Archive

syslinux current dir
Hi,

It'm trying to put together Finnix, Knoppix, DSL, etc. on a single
multi-bootable USB stick. The new syslinux capability to load a new
config file is almost perfect for this purpose... apart that I can't
find a way to change the current directory so that I can keep the
unmodified config files of the different distributions in separate
directories. That would cut down on manual maintenance a lot. Is
there a way, which I just couldn't find? If not, can I put a feature
request for it?
--
Thanks,
Feri.

_______________________________________________
SYSLINUX mailing list
Submissions to SYSLINUX@zytor.com
Unsubscribe or set options at:
http://www.zytor.com/mailman/listinfo/syslinux
Please do not send private replies to mailing list traffic.
Re: syslinux current dir [ In reply to ]
Wagner Ferenc wrote:
> Hi,
>
> It'm trying to put together Finnix, Knoppix, DSL, etc. on a single
> multi-bootable USB stick. The new syslinux capability to load a new
> config file is almost perfect for this purpose... apart that I can't
> find a way to change the current directory so that I can keep the
> unmodified config files of the different distributions in separate
> directories. That would cut down on manual maintenance a lot. Is
> there a way, which I just couldn't find? If not, can I put a feature
> request for it?

That makes sense, and *should* be implementable.

-hpa

_______________________________________________
SYSLINUX mailing list
Submissions to SYSLINUX@zytor.com
Unsubscribe or set options at:
http://www.zytor.com/mailman/listinfo/syslinux
Please do not send private replies to mailing list traffic.
Re: syslinux current dir [ In reply to ]
"H. Peter Anvin" <hpa@zytor.com> writes:

> Wagner Ferenc wrote:
>
>> It'm trying to put together Finnix, Knoppix, DSL, etc. on a single
>> multi-bootable USB stick. The new syslinux capability to load a new
>> config file is almost perfect for this purpose... apart that I can't
>> find a way to change the current directory so that I can keep the
>> unmodified config files of the different distributions in separate
>> directories. That would cut down on manual maintenance a lot. Is
>> there a way, which I just couldn't find? If not, can I put a feature
>> request for it?
>
> That makes sense, and *should* be implementable.

Do you mean that I should implement it? :)
My asm-fu is rather weak, but might try...
--
Feri.

_______________________________________________
SYSLINUX mailing list
Submissions to SYSLINUX@zytor.com
Unsubscribe or set options at:
http://www.zytor.com/mailman/listinfo/syslinux
Please do not send private replies to mailing list traffic.
Re: syslinux current dir [ In reply to ]
Wagner Ferenc wrote:
>> That makes sense, and *should* be implementable.
>
> Do you mean that I should implement it? :)
> My asm-fu is rather weak, but might try...

If you're willing to try it, go for it. I suggest making the new cwd a
command-line option (append) to the config file, but that's only one
alternative.

-hpa

_______________________________________________
SYSLINUX mailing list
Submissions to SYSLINUX@zytor.com
Unsubscribe or set options at:
http://www.zytor.com/mailman/listinfo/syslinux
Please do not send private replies to mailing list traffic.
Re: syslinux current dir [ In reply to ]
"H. Peter Anvin" <hpa@zytor.com> writes:

> Wagner Ferenc wrote:
>>> That makes sense, and *should* be implementable.
>>
>> Do you mean that I should implement it? :)
>> My asm-fu is rather weak, but might try...
>
> If you're willing to try it, go for it. I suggest making the new cwd a
> command-line option (append) to the config file, but that's only one
> alternative.

So here we go, my first shot at the problem. It doesn't work. Also,
I find it somewhat uglier than necessary, but my asm skills are nearly
nonexistent... The concept should be clear though, I hope. I'm not
sure how to send git commits, maybe git diff -p is somewhat usable...
I'm testing with the following syslinux.cfg in the root of the floppy:

serial 1
prompt 1
timeout 100
say say hello

label hello
config syslinux.cfg
append elso cWd=dir1 masodik=ertek cwD=dir2 utolso

Unfortunately, uncommenting the mov [CurrentDir],eax statement hangs
syslinux; maybe because I know very little about its concept of the
current directory, maybe becasue I'm not into assembly programming.
Anyway, I'm out of ideas for now, and could use some help or comments.
--
Thanks,
Feri.

commit 088b568ccf73e3c5f3cef7cfca7b0a599ceae5c3
Author: Ferenc Wagner <wferi@tac.ki.iif.hu>
Date: Fri May 11 17:20:32 2007 +0200

Prepare for changing current working directory

Things seem to work together as expected, but uncommenting the FIXME line
(which constitutes the main effect) locks up my test.
Some debugging is in order.

diff --git a/ldlinux.asm b/ldlinux.asm
index 3cfa13e..9c0e92f 100644
--- a/ldlinux.asm
+++ b/ldlinux.asm
@@ -1075,7 +1075,61 @@ search_dos_dir:
;
; Assumes CS == DS == ES, and trashes BX and CX.
;
-searchdir:
+searchdir: call searchpath
+ test dl,18h ; Subdirectory|Volume Label
+ jnz badfile ; If not a file, it's a bad thing
+
+ ; SI and EAX are already set
+ mov edx,eax
+ shr edx,16 ; Old 16-bit remnant...
+ and eax,eax ; EAX != 0
+ jz badfile
+ ret ; Done!
+
+;
+; cwdir:
+;
+; Change current working directory
+;
+; On entry:
+; DS:DI = directory name
+; If successful:
+; ZF clear
+; If unsuccessful
+; ZF set
+;
+cwdir: push es
+ mov ax,ds ; Ensure ES == DS
+ mov es,ax
+ call searchpath
+ test dl,10h ; Subdirectory
+ pop es
+ jz badfile
+
+ xor eax,eax
+ xchg eax,[si+file_sector] ; Get sector number and free file structure
+; mov [CurrentDir],eax ; FIXME
+ and ax,ax ; Clear ZF
+ ret
+
+;
+; searchpath:
+;
+; Look up a directory entry
+;
+; On entry:
+; DS:DI = pathname
+; If successful:
+; ZF clear
+; SI = file pointer
+; EAX = file length in bytes
+; DL = file attributes
+; If unsuccessful
+; ZF set
+;
+; Assumes CS == DS == ES, and trashes BX and CX.
+;
+searchpath:
mov eax,[CurrentDir]
cmp byte [di],'/' ; Root directory?
jne .notroot
@@ -1102,37 +1156,26 @@ searchdir:
call mangle_dos_name ; MangledBuf <- component
call search_dos_dir
pop di
- jz .notfound ; Pathname component missing
+ jz notfound ; Pathname component missing

cmp byte [di-1],'/' ; Do we expect a directory
je .isdir
-
- ; Otherwise, it should be a file
-.isfile:
- test dl,18h ; Subdirectory|Volume Label
- jnz .badfile ; If not a file, it's a bad thing
-
- ; SI and EAX are already set
- mov edx,eax
- shr edx,16 ; Old 16-bit remnant...
- and eax,eax ; EAX != 0
- jz .badfile
- ret ; Done!
+ ret

; If we expected a directory, it better be one...
.isdir:
test dl,10h ; Subdirectory
- jz .badfile
+ jz badfile

xor eax,eax
xchg eax,[si+file_sector] ; Get sector number and free file structure
jmp .pathwalk ; Walk the next bit of the path

-.badfile:
+badfile:
xor eax,eax
mov [si],eax ; Free file structure

-.notfound:
+notfound:
xor eax,eax
xor dx,dx
ret
diff --git a/ui.inc b/ui.inc
index f78f358..8afc21e 100644
--- a/ui.inc
+++ b/ui.inc
@@ -560,9 +560,8 @@ is_config_file:
call strcpy
push ds ; not sure if needed
mov si,real_mode_seg
- mov ds,si
+ mov ds,si ; for accessing the command line
mov si,cmd_line_here
- call cwritestr ; debug (writes to EOL, not the parameter only)
.get_next_opt: lodsb ; copied from runkernel.inc
and al,al
jz .cmdline_end
@@ -575,7 +574,21 @@ is_config_file:
jne .skip_this_opt

add si,4 ; found CWD command
+ mov di,si
+ push di ; save for printing
+ call cwdir
+ pop di
+ mov si,di ; in case we skip
+ jnz .skip_this_opt
+ pop ds ; restore DS
+ push ds
+ mov si,err_cwdir ; for printing the error
call cwritestr
+ mov si,real_mode_seg ; then change back
+ mov ds,si
+ mov si,di
+ call cwritestr ; for printing the directory
+ call crlf

.skip_this_opt: lodsb
cmp al,' '
@@ -607,6 +620,7 @@ is_disk_image equ is_bad_image

section .data
err_badimage db 'Invalid image type for this media type!', CR, LF, 0
+err_cwdir db 'Cannot change working directory to ', 0

align 2, db 0
kerneltype_table:

commit b2167f8dbe62b35f10eb44db8349bf4b0137e3ab
Author: Ferenc Wagner <wferi@tac.ki.iif.hu>
Date: Fri May 11 12:32:56 2007 +0200

Parse the CMD option for a new config file.

Now for debugging only, printing some text on the
console without any effect.

diff --git a/ui.inc b/ui.inc
index 97d361e..f78f358 100644
--- a/ui.inc
+++ b/ui.inc
@@ -558,6 +558,31 @@ is_config_file:
mov si,KernelCName ; Save the config file name, for posterity
mov di,ConfigName
call strcpy
+ push ds ; not sure if needed
+ mov si,real_mode_seg
+ mov ds,si
+ mov si,cmd_line_here
+ call cwritestr ; debug (writes to EOL, not the parameter only)
+.get_next_opt: lodsb ; copied from runkernel.inc
+ and al,al
+ jz .cmdline_end
+ cmp al,' '
+ jbe .get_next_opt
+ dec si
+ mov eax,[si]
+ or eax,202020h ; Force lower case (except =)
+ cmp eax,'cwd='
+ jne .skip_this_opt
+
+ add si,4 ; found CWD command
+ call cwritestr
+
+.skip_this_opt: lodsb
+ cmp al,' '
+ ja .skip_this_opt
+ dec si
+ jmp short .get_next_opt
+.cmdline_end: pop ds ; restore DS
popa
call openfd
call reset_config

_______________________________________________
SYSLINUX mailing list
Submissions to SYSLINUX@zytor.com
Unsubscribe or set options at:
http://www.zytor.com/mailman/listinfo/syslinux
Please do not send private replies to mailing list traffic.
Re: syslinux current dir [ In reply to ]
Ferenc Wagner <wferi@niif.hu> writes:

> So here we go, my first shot at the problem. It doesn't work.

Any word on this approach? I couldn't hunt for the bug yet.
--
Thanks,
Feri.

_______________________________________________
SYSLINUX mailing list
Submissions to SYSLINUX@zytor.com
Unsubscribe or set options at:
http://www.zytor.com/mailman/listinfo/syslinux
Please do not send private replies to mailing list traffic.
Re: syslinux current dir [ In reply to ]
Ferenc Wagner wrote:
> Ferenc Wagner <wferi@niif.hu> writes:
>
>> So here we go, my first shot at the problem. It doesn't work.
>
> Any word on this approach? I couldn't hunt for the bug yet.

It seems it should work for SYSLINUX, EXTLINUX and ISOLINUX. PXELINUX
needs separate handling, since its "current directory" is a
server+prefix combination.

-hpa

_______________________________________________
SYSLINUX mailing list
Submissions to SYSLINUX@zytor.com
Unsubscribe or set options at:
http://www.zytor.com/mailman/listinfo/syslinux
Please do not send private replies to mailing list traffic.
Re: syslinux current dir [ In reply to ]
"H. Peter Anvin" <hpa@zytor.com> writes:

> Ferenc Wagner wrote:
>> Ferenc Wagner <wferi@niif.hu> writes:
>>
>>> So here we go, my first shot at the problem. It doesn't work.
>>
>> Any word on this approach? I couldn't hunt for the bug yet.
>
> It seems it should work for SYSLINUX, EXTLINUX and ISOLINUX. PXELINUX
> needs separate handling, since its "current directory" is a
> server+prefix combination.

Yep, I forgot about that. The prefix change is probably analogous (I
didn't check), hope the server change is easy, too. But I guess
that's not too important to have.

Too bad the patch doesn't work (not that I expected that). I'll check
for some invalidated registers, and come back for advice if I can't
find the bug.
--
Regards,
Feri.

_______________________________________________
SYSLINUX mailing list
Submissions to SYSLINUX@zytor.com
Unsubscribe or set options at:
http://www.zytor.com/mailman/listinfo/syslinux
Please do not send private replies to mailing list traffic.
Re: syslinux current dir [ In reply to ]
Ferenc Wagner wrote:
> "H. Peter Anvin" <hpa@zytor.com> writes:
>
>> Ferenc Wagner wrote:
>>> Ferenc Wagner <wferi@niif.hu> writes:
>>>
>>>> So here we go, my first shot at the problem. It doesn't work.
>>> Any word on this approach? I couldn't hunt for the bug yet.
>> It seems it should work for SYSLINUX, EXTLINUX and ISOLINUX. PXELINUX
>> needs separate handling, since its "current directory" is a
>> server+prefix combination.
>
> Yep, I forgot about that. The prefix change is probably analogous (I
> didn't check), hope the server change is easy, too. But I guess
> that's not too important to have.

Actually for a lot of users, it's *very* important. It should be quite
easy, though.

> Too bad the patch doesn't work (not that I expected that). I'll check
> for some invalidated registers, and come back for advice if I can't
> find the bug.

I recommend setting up a simulator -- you can use Qemu with gdb, or
Bochs (which has an internal debugger), for example; AMD also has a
downloadable version of SimNow! available.

-hpa

_______________________________________________
SYSLINUX mailing list
Submissions to SYSLINUX@zytor.com
Unsubscribe or set options at:
http://www.zytor.com/mailman/listinfo/syslinux
Please do not send private replies to mailing list traffic.
Re: syslinux current dir [ In reply to ]
"H. Peter Anvin" <hpa@zytor.com> writes:

> Ferenc Wagner wrote:
>> "H. Peter Anvin" <hpa@zytor.com> writes:
>>
>>> Ferenc Wagner wrote:
>>>> Ferenc Wagner <wferi@niif.hu> writes:
>>>>
>>>>> So here we go, my first shot at the problem. It doesn't work.
>>>> Any word on this approach? I couldn't hunt for the bug yet.
>>> It seems it should work for SYSLINUX, EXTLINUX and ISOLINUX. PXELINUX
>>> needs separate handling, since its "current directory" is a
>>> server+prefix combination.
>>
>> Yep, I forgot about that. The prefix change is probably analogous (I
>> didn't check), hope the server change is easy, too. But I guess
>> that's not too important to have.
>
> Actually for a lot of users, it's *very* important. It should be quite
> easy, though.

I guessed wrong. Not for the last, a guess... ;)

>> Too bad the patch doesn't work (not that I expected that). I'll check
>> for some invalidated registers, and come back for advice if I can't
>> find the bug.
>
> I recommend setting up a simulator -- you can use Qemu with gdb,

I was afraid of that. :) By the way, why is so much of the code in
assembly? Is it too cumbersome to handle the real mode segmented
model in C? People were doing it for quite some time, weren't they?

> or Bochs (which has an internal debugger), for example; AMD also has
> a downloadable version of SimNow! available.

I know Qemu and gdb, perhaps it's better to start with those.
(Oh dear, I really didn't mean to get here!) Is there a way to get
syslinux symbol information into gdb?
--
Feri.

_______________________________________________
SYSLINUX mailing list
Submissions to SYSLINUX@zytor.com
Unsubscribe or set options at:
http://www.zytor.com/mailman/listinfo/syslinux
Please do not send private replies to mailing list traffic.
Re: syslinux current dir [ In reply to ]
Ferenc Wagner wrote:
>
> I was afraid of that. :) By the way, why is so much of the code in
> assembly? Is it too cumbersome to handle the real mode segmented
> model in C? People were doing it for quite some time, weren't they?
>

Mostly a lack of freely available compilers (there is OpenWatcom, but
it's not readily packaged for Linux hosting, and is very hard for users
to build themselves), and historical reasons.

>> or Bochs (which has an internal debugger), for example; AMD also has
>> a downloadable version of SimNow! available.
>
> I know Qemu and gdb, perhaps it's better to start with those.
> (Oh dear, I really didn't mean to get here!) Is there a way to get
> syslinux symbol information into gdb?

Unfortunately I don't think so.

-hpa

_______________________________________________
SYSLINUX mailing list
Submissions to SYSLINUX@zytor.com
Unsubscribe or set options at:
http://www.zytor.com/mailman/listinfo/syslinux
Please do not send private replies to mailing list traffic.
Re: syslinux current dir [ In reply to ]
"H. Peter Anvin" <hpa@zytor.com> writes:

>> Is there a way to get syslinux symbol information into gdb?
>
> Unfortunately I don't think so.

I had some success by generating a dummy as source file full of .stabs
directives, based on ldlinux.map. It lets me insert breakpoints via
labels at least. However, nasm can generate stabs info for the elf
output format, which would be more fun to use. If only ldlinux.asm
could be assembled into elf format. Problems start at the org
directive, which is accepted for the bin format only... Can't you
perhaps think of a way around? Then the debugging info could be
loaded from that after gdb was attached to qemu.
--
Thanks,
Feri.

_______________________________________________
SYSLINUX mailing list
Submissions to SYSLINUX@zytor.com
Unsubscribe or set options at:
http://www.zytor.com/mailman/listinfo/syslinux
Please do not send private replies to mailing list traffic.
Re: syslinux current dir [ In reply to ]
Wagner Ferenc wrote:
> "H. Peter Anvin" <hpa@zytor.com> writes:
>
>>> Is there a way to get syslinux symbol information into gdb?
>> Unfortunately I don't think so.
>
> I had some success by generating a dummy as source file full of .stabs
> directives, based on ldlinux.map. It lets me insert breakpoints via
> labels at least. However, nasm can generate stabs info for the elf
> output format, which would be more fun to use. If only ldlinux.asm
> could be assembled into elf format. Problems start at the org
> directive, which is accepted for the bin format only... Can't you
> perhaps think of a way around? Then the debugging info could be
> loaded from that after gdb was attached to qemu.

That can be dealt with with a linker script, but what's a much bigger
problem is cross-section references, which are harder to represent in NASM.

For ELF, you would just drop the org directive (which just tells the bin
format linker where the file starts) and instead use the linker script,
or even a post-processing script. Easy enough.

Now, that being said, I think that the current SYSLINUX probably could
be much easier switched over to the ELF format than last time I tried
it. It's not a high priority for me (I tend to use bochs rather than
qemu+gdb to debug, mostly because I think there are too many bugs in
qemu's debugger interface) so I don't think it'll get done any time soon.

-hpa

_______________________________________________
SYSLINUX mailing list
Submissions to SYSLINUX@zytor.com
Unsubscribe or set options at:
http://www.zytor.com/mailman/listinfo/syslinux
Please do not send private replies to mailing list traffic.
Re: syslinux current dir [ In reply to ]
"H. Peter Anvin" <hpa@zytor.com> writes:

> Wagner Ferenc wrote:
>> "H. Peter Anvin" <hpa@zytor.com> writes:
>>
>>>> Is there a way to get syslinux symbol information into gdb?
>>> Unfortunately I don't think so.
>>
>> I had some success by generating a dummy as source file full of .stabs
>> directives, based on ldlinux.map. It lets me insert breakpoints via
>> labels at least. However, nasm can generate stabs info for the elf
>> output format, which would be more fun to use. If only ldlinux.asm
>> could be assembled into elf format. Problems start at the org
>> directive, which is accepted for the bin format only... Can't you
>> perhaps think of a way around? Then the debugging info could be
>> loaded from that after gdb was attached to qemu.
>
> That can be dealt with with a linker script, but what's a much bigger
> problem is cross-section references, which are harder to represent in NASM.
>
> For ELF, you would just drop the org directive (which just tells the bin
> format linker where the file starts) and instead use the linker script,
> or even a post-processing script. Easy enough.

Well, not really. Dropping the org directive resulted in:

$ nasm -O99 -f elf -DDATE_STR="'0x4656f708'" -DHEXDATE="0x4656f708" -o ldlinux.elf ldlinux.asm
ldlinux.asm:72: warning: section attributes ignored on redeclaration of section `.stack'
ldlinux.asm:93: warning: section attributes ignored on redeclaration of section `.stack'
ldlinux.asm:563: error: TIMES value -75 is negative
ldlinux.asm:751: error: Sector 1 overflow

and I got lost. Looks like size computation gone wrong, and
commenting it resulted in

cpuinit.inc:45: error: symbol `section..bcopy32.start' undefined
ui.inc:110: error: short jump is out of range
ui.inc:177: error: short jump is out of range
configinit.inc:25: error: symbol `section..config.start' undefined
configinit.inc:26: error: symbol `section..config.vstart' undefined
configinit.inc:27: error: symbol `section..config.end.start' undefined
ldlinux.asm:1689: error: phase error detected at end of assembly.

where I gave up. I didn't care about linker scripts, I aimed for much
less: just wanted to extract the debugging info out of the elf, not to
use the code within.
--
Feri.

_______________________________________________
SYSLINUX mailing list
Submissions to SYSLINUX@zytor.com
Unsubscribe or set options at:
http://www.zytor.com/mailman/listinfo/syslinux
Please do not send private replies to mailing list traffic.