Create a hook 'post-initialize' for people that want to define

something (perhaps in loader.rc.local) that can read in .conf files
after all the other .conf files have been read and override settings
in them. This is quite handy if the .conf file name is determined
while the loader is running, but might be generically useful for other
things. If this hook exists, call it, otherwise don't do anything.

Doing it in these functions ensures that this file is reliably
read. It also works around a defect in forth where s" isn't allowed
outside a function (well, in a compile context) leading to gross
workarounds if one were to hack loader.rc like:

: maybe-some-func s" some-func" sfind if execute else drop then ;
maybe-some-func

which somehow seems worse. Though I'm sure there's some clever forthy
way of doing that with a macro.

Sponsored by: Netflix, Inc
This commit is contained in:
Warner Losh 2016-08-31 03:55:50 +00:00
parent 591ef90abd
commit 0b1c7ee322

View File

@ -143,6 +143,8 @@ only forth definitions also support-functions
s" /boot/defaults/loader.conf" initialize
include_conf_files
include_nextboot_file
\ If the user defined a post-initialize hook, call it now
s" post-initialize" sfind if execute else drop then
\ Will *NOT* try to load kernel and modules if no configuration file
\ was successfully loaded!
any_conf_read? if
@ -165,12 +167,15 @@ only forth definitions also support-functions
\
\ Overrides support.4th initialization word with one that does
\ everything start one does, short of loading the kernel and
\ modules. Returns a flag
\ modules. Returns a flag. Unsure why we don't just have start
\ call this...
: initialize ( -- flag )
s" /boot/defaults/loader.conf" initialize
include_conf_files
include_nextboot_file
\ If the user defined a post-initialize hook, call it now
s" post-initialize" sfind if execute else drop then
any_conf_read?
;