Add support for reading an additional loader configuration file. By default,
this is called /boot/nextboot.conf. This file is required to have it's first line be nextboot_enable="YES" for it to be read. Also, this file is rewritten by the loader to nextboot_enable="NO"<space> after it is read. This makes it so the file is read exactly once. Finally, the nextboot.conf is removed shortly after the filesystems are mounted r/w. Caution should be taken as you can shoot yourself in the foot. This is only the loader piece. There will be a tool called nextboot(8) that will manage the nextboot.conf file for you. It is coming shortly. Reviewed by: dcs Approved by: jake (mentor)
This commit is contained in:
parent
f6c55bbe1c
commit
faffa2a33d
@ -134,6 +134,7 @@ only forth definitions also support-functions
|
||||
: start ( -- ) ( throws: abort & user-defined )
|
||||
s" /boot/defaults/loader.conf" initialize
|
||||
include_conf_files
|
||||
include_nextboot_file
|
||||
\ Will *NOT* try to load kernel and modules if no configuration file
|
||||
\ was succesfully loaded!
|
||||
any_conf_read? if
|
||||
@ -151,6 +152,7 @@ only forth definitions also support-functions
|
||||
: initialize ( -- flag )
|
||||
s" /boot/defaults/loader.conf" initialize
|
||||
include_conf_files
|
||||
include_nextboot_file
|
||||
any_conf_read?
|
||||
;
|
||||
|
||||
|
@ -22,7 +22,9 @@ userconfig_script_load="NO"
|
||||
userconfig_script_name="/boot/kernel.conf"
|
||||
userconfig_script_type="userconfig_script"
|
||||
|
||||
loader_conf_files="/boot/device.hints /boot/loader.conf /boot/loader.conf.local /boot/nextboot.conf"
|
||||
loader_conf_files="/boot/device.hints /boot/loader.conf /boot/loader.conf.local"
|
||||
nextboot_conf="/boot/nextboot.conf"
|
||||
nextboot_enable="NO"
|
||||
|
||||
verbose_loading="NO" # Set to YES for verbose loader output
|
||||
|
||||
|
@ -208,10 +208,12 @@ structure: pnpinfo
|
||||
\ Global variables
|
||||
|
||||
string conf_files
|
||||
string nextboot_conf_file
|
||||
string password
|
||||
create module_options sizeof module.next allot 0 module_options !
|
||||
create last_module_option sizeof module.next allot 0 last_module_option !
|
||||
0 value verbose?
|
||||
0 value nextboot?
|
||||
|
||||
\ Support string functions
|
||||
|
||||
@ -660,6 +662,14 @@ only forth also support-functions also file-processing definitions also
|
||||
s" loader_conf_files" assignment_type?
|
||||
;
|
||||
|
||||
: nextboot_flag?
|
||||
s" nextboot_enable" assignment_type?
|
||||
;
|
||||
|
||||
: nextboot_conf?
|
||||
s" nextboot_conf" assignment_type?
|
||||
;
|
||||
|
||||
: verbose_flag?
|
||||
s" verbose_loading" assignment_type?
|
||||
;
|
||||
@ -713,6 +723,19 @@ only forth also support-functions also file-processing definitions also
|
||||
conf_files .len ! conf_files .addr !
|
||||
;
|
||||
|
||||
: set_nextboot_conf
|
||||
nextboot_conf_file .addr @ ?dup if
|
||||
free-memory
|
||||
then
|
||||
value_buffer .addr @ c@ [char] " = if
|
||||
value_buffer .addr @ char+ value_buffer .len @ 2 chars -
|
||||
else
|
||||
value_buffer .addr @ value_buffer .len @
|
||||
then
|
||||
strdup
|
||||
nextboot_conf_file .len ! nextboot_conf_file .addr !
|
||||
;
|
||||
|
||||
: append_to_module_options_list ( addr -- )
|
||||
module_options @ 0= if
|
||||
dup module_options !
|
||||
@ -863,6 +886,10 @@ only forth also support-functions also file-processing definitions also
|
||||
then
|
||||
;
|
||||
|
||||
: set_nextboot_flag
|
||||
yes_value? to nextboot?
|
||||
;
|
||||
|
||||
: set_verbose
|
||||
yes_value? to verbose?
|
||||
;
|
||||
@ -890,6 +917,8 @@ only forth also support-functions also file-processing definitions also
|
||||
: process_assignment
|
||||
name_buffer .len @ 0= if exit then
|
||||
loader_conf_files? if set_conf_files exit then
|
||||
nextboot_flag? if set_nextboot_flag exit then
|
||||
nextboot_conf? if set_nextboot_conf exit then
|
||||
verbose_flag? if set_verbose exit then
|
||||
execute? if execute_command exit then
|
||||
password? if set_password exit then
|
||||
@ -939,6 +968,19 @@ support-functions definitions
|
||||
repeat
|
||||
;
|
||||
|
||||
: peek_file
|
||||
0 to end_of_file?
|
||||
reset_line_reading
|
||||
O_RDONLY fopen fd !
|
||||
fd @ -1 = if open_error throw then
|
||||
reset_assignment_buffers
|
||||
read_line
|
||||
get_assignment
|
||||
['] process_assignment catch
|
||||
['] free_buffers catch
|
||||
fd @ fclose
|
||||
;
|
||||
|
||||
only forth also support-functions definitions
|
||||
|
||||
\ Interface to loading conf files
|
||||
@ -1101,6 +1143,29 @@ variable current_conf_files
|
||||
repeat
|
||||
;
|
||||
|
||||
: get_nextboot_conf_file ( -- addr len )
|
||||
nextboot_conf_file .addr @ nextboot_conf_file .len @ strdup
|
||||
;
|
||||
|
||||
: rewrite_nextboot_file ( -- )
|
||||
get_nextboot_conf_file
|
||||
O_WRONLY fopen fd !
|
||||
fd @ -1 = if open_error throw then
|
||||
fd @ s' nextboot_enable="NO" ' fwrite
|
||||
fd @ fclose
|
||||
;
|
||||
|
||||
: include_nextboot_file
|
||||
get_nextboot_conf_file
|
||||
['] peek_file catch
|
||||
nextboot? if
|
||||
get_nextboot_conf_file
|
||||
['] load_conf catch
|
||||
process_conf_errors
|
||||
['] rewrite_nextboot_file catch
|
||||
then
|
||||
;
|
||||
|
||||
\ Module loading functions
|
||||
|
||||
: load_module?
|
||||
|
Loading…
x
Reference in New Issue
Block a user