Chris wrote:
>
> I am attempting to add some functionality to the loader, but have come
> across a minor problem. Is there some way to include forth files,
> given a string?
>
> s" file" included (gforth example)
Yes, there is... I just can't recall the exact name right now. :-)
You can always do a s" include file" evaluate, but... :-)
Also, "include" is a builtin, so you can pass arguments to it when
compiling it:
: whatever s" file" include ;
Read the finer details for builtins on the loader.4th(8) man page, or,
worse yet, check out it's exact definition on
/sys/boot/common/interp_forth.c. Their behavior is highly complex...
> What I would like to do is read in a /boot/loader.rc.$ip or something
> similar. This would allow a number of machines to be booted diskless
> and yet have different boot configurations.
IMHO, what *should* be done is expanding environment variables in the
loader_conf_files="xyzyz" lines. Previously, there was no support in
loader(8) to be able to do this on support.4th, but now there is. A
function that went through all environment variables in a string and
expanded them would be an useful addition in a number of places. One
such a function is written, it can be used at set_conf_files, right
after strdup.
Then you can have loader_conf_files="loader.conf.$ip". If you still wish
to have Forth code executing, you can just place an exec="include
loader.rc.whatever" line there, but I'd prefer to keep the configuration
passive as much as possible.
> : read_loader_rc_specific
> s" boot.netif.hwaddr" getenv
> dup -1 = if
> drop
> s" boot.netif.ip" getenv
> dup -1 = if
> drop 0 0
> then
> then
> s" /boot/loader.rc."
> 2over nip over + allocate
> if ( out of memory )
> 2drop 2drop
> 100 exit
> then
> 0 2swap strcat 2swap strcat
> read-conf
> ;
read-conf reads conf files, it doesn't execute anything.
In a private discussion long ago, Jordan said he would like for .rc and
.4th files to remain scripts, and .conf files to be variable-setting
files (like they are now :). Except, of course, that there are a couple
of exceptions on the .conf files format to allow for the cases where it
is absolutely necessary to execute code.
--
Daniel C. Sobral (8-DCS)
[EMAIL PROTECTED]
[EMAIL PROTECTED]
[EMAIL PROTECTED]
"There is no spoon." -- Kiki
To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-hackers" in the body of the message