>Number:         172529
>Category:       bin
>Synopsis:       Non-default boot_verbose=YES in loader.conf(5) not displayed 
>by beastie menu
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          maintainer-update
>Submitter-Id:   current-users
>Arrival-Date:   Tue Oct 09 22:30:13 UTC 2012
>Closed-Date:
>Last-Modified:
>Originator:     Devin Teske
>Release:        FreeBSD 9.0-RELEASE i386
>Organization:
FIS Global, Inc. -- VICOR Business Unit (VBU)
>Environment:
FreeBSD scribe9.vicor.com 9.0-RELEASE FreeBSD 9.0-RELEASE #0: Tue Jan  3 
07:15:25 UTC 2012     [email protected]:/usr/obj/usr/src/sys/GENERIC  
i386
>Description:
Since the introduction of the new advanced boot menu (r222417), options like 
"boot verbose", "single user mode", "ACPI" and more are now stateful boolean 
menuitems rather than direct action-items.

A short-coming in this new menu system is that when a user sets a non-default 
value in loader.conf(5), this non-default state is not reflected in the menu -- 
leading to confusion as to whether the option was taking effect or not.

If nobody objects, I will commit the attached patch.txt to add dynamic menuitem 
constructors _and_ the necessary Forth callbacks to initialize these menuitems.

Once applied, the aforementioned menuitems will adhere to loader.conf(5) 
settings.
>How-To-Repeat:
Add boot_verbose="YES" to loader.conf(5) and reboot. Notice that the "Verbose" 
option in the beastie menu still says "Verbose... off".
>Fix:
See attached patch.txt.

Patch attached with submission follows:

Index: menu-commands.4th
===================================================================
--- menu-commands.4th   (revision 241367)
+++ menu-commands.4th   (working copy)
@@ -26,6 +26,9 @@
 
 marker task-menu-commands.4th
 
+variable kernel_state
+variable root_state
+
 : acpi_enable ( -- )
        s" set acpi_load=YES" evaluate \ XXX deprecated but harmless
        s" set hint.acpi.0.disabled=0" evaluate
@@ -53,6 +56,13 @@ marker task-menu-commands.4th
        TRUE \ loop menu again
 ;
 
+: init_safemode ( N -- N )
+       s" kern.smp.disabled" getenv -1 <> if
+               drop ( n c-addr -- n ) \ unused
+               toggle_menuitem ( n -- n )
+       then
+;
+
 : toggle_safemode ( N -- N TRUE )
        toggle_menuitem
 
@@ -84,6 +94,13 @@ marker task-menu-commands.4th
        TRUE \ loop menu again
 ;
 
+: init_singleuser ( N -- N )
+       s" boot_single" getenv -1 <> if
+               drop ( n c-addr -- n ) \ unused
+               toggle_menuitem ( n -- n )
+       then
+;
+
 : toggle_singleuser ( N -- N TRUE )
        toggle_menuitem
        menu-redraw
@@ -102,6 +119,13 @@ marker task-menu-commands.4th
        TRUE \ loop menu again
 ;
 
+: init_verbose ( N -- N )
+       s" boot_verbose" getenv -1 <> if
+               drop ( n c-addr -- n ) \ unused
+               toggle_menuitem ( n -- n )
+       then
+;
+
 : toggle_verbose ( N -- N TRUE )
        toggle_menuitem
        menu-redraw
@@ -132,6 +156,27 @@ marker task-menu-commands.4th
        FALSE \ exit the menu
 ;
 
+: init_cyclestate ( N K -- N )
+       over                   ( n k -- n k n )
+       s" cycle_stateN"       ( n k n -- n k n c-addr u )
+       -rot tuck 11 + c! swap ( n k n c-addr u -- n k c-addr u )
+       evaluate               ( n k c-addr u -- n k addr )
+       begin
+               tuck @  ( n k addr -- n addr k c )
+               over <> ( n addr k c -- n addr k 0|-1 )
+       while
+               rot ( n addr k -- addr k n )
+               cycle_menuitem
+               swap rot ( addr k n -- n k addr )
+       repeat
+       2drop ( n k addr -- n )
+;
+
+: init_kernel ( N -- N )
+       kernel_state @  ( n -- n k )
+       init_cyclestate ( n k -- n )
+;
+
 : cycle_kernel ( N -- N TRUE )
        cycle_menuitem
        menu-redraw
@@ -142,6 +187,7 @@ marker task-menu-commands.4th
        -rot 2dup 11 + c! rot    \ replace 'N' with ASCII numeral
        evaluate                 \ translate name into address
        @                        \ dereference address into value
+       dup kernel_state !       \ save a copy for re-initialization
        48 +                     \ convert to ASCII numeral
 
        s" set kernel=${kernel_prefix}${kernel[N]}${kernel_suffix}"
@@ -152,6 +198,11 @@ marker task-menu-commands.4th
        TRUE \ loop menu again
 ;
 
+: init_root ( N -- N )
+       root_state @    ( n -- n k )
+       init_cyclestate ( n k -- n )
+;
+
 : cycle_root ( N -- N TRUE )
        cycle_menuitem
        menu-redraw
@@ -162,6 +213,7 @@ marker task-menu-commands.4th
        -rot 2dup 11 + c! rot    \ replace 'N' with ASCII numeral
        evaluate                 \ translate name into address
        @                        \ dereference address into value
+       dup root_state !         \ save a copy for re-initialization
        48 +                     \ convert to ASCII numeral
 
        s" set root=${root_prefix}${root[N]}${root_suffix}"
Index: menu.4th
===================================================================
--- menu.4th    (revision 241365)
+++ menu.4th    (working copy)
@@ -76,6 +76,16 @@ variable menu_timeout         \ determined configu
 variable menu_timeout_x       \ column position of timeout message
 variable menu_timeout_y       \ row position of timeout message
 
+\ Menu initialization status variables
+variable init_state1
+variable init_state2
+variable init_state3
+variable init_state4
+variable init_state5
+variable init_state6
+variable init_state7
+variable init_state8
+
 \ Boolean option status variables
 variable toggle_state1
 variable toggle_state2
@@ -421,6 +431,16 @@ create init_text8 255 allot
        then
        24 over 2 / - 9 at-xy type 
 
+       \ If $menu_init is set, evaluate it (allowing for whole menus to be
+       \ constructed dynamically -- as this function could conceivably set
+       \ the remaining environment variables to construct the menu entirely).
+       \ 
+       s" menu_init" getenv dup -1 <> if
+               evaluate
+       else
+               drop
+       then
+
        \ Print our menu options with respective key/variable associations.
        \ `printmenuitem' ends by adding the decimal ASCII value for the
        \ numerical prefix to the stack. We store the value left on the stack
@@ -499,6 +519,24 @@ create init_text8 255 allot
                dup menuacpi @ = if
                        acpimenuitem ( -- C-Addr/U | -1 )
                else
+                       \ make sure we have not already initialized this item
+                       s" init_stateN"
+                       -rot 2dup 10 + c! rot \ repace 'N'
+                       evaluate dup @ 0= if
+                               1 swap !
+
+                               \ If this menuitem has an initializer, run it
+                               s" menu_init[x]"
+                               -rot 2dup 10 + c! rot \ replace 'x'
+                               getenv dup -1 <> if
+                                       evaluate
+                               else
+                                       drop
+                               then
+                       else
+                               drop
+                       then
+
                        loader_color? if
                                s" ansi_caption[x]"
                        else
@@ -917,6 +955,10 @@ create init_text8 255 allot
                -rot 2dup 13 + c! rot   \ replace 'x'
                unsetenv
 
+               s" menu_init[x]"        \ initializer basename
+               -rot 2dup 10 + c! rot   \ replace 'x'
+               unsetenv
+
                s" menu_keycode[x]"     \ keycode basename
                -rot 2dup 13 + c! rot   \ replace 'x'
                unsetenv
@@ -959,6 +1001,10 @@ create init_text8 255 allot
                -rot 2dup 9 + c! rot    \ replace 'N' with current iteration
                evaluate                \ assign zero (0) to key assoc. var
 
+               s" 0 init_stateN !"     \ used by menu-create
+               -rot 2dup 12 + c! rot   \ replace 'N'
+               evaluate
+
                1+ dup 56 >     \ increment, continue if less than 57
        until
        drop \ iterator
@@ -979,6 +1025,8 @@ create init_text8 255 allot
        s" menu_optionstext" unsetenv
        0 menuoptions !
 
+       \ clear the menu initializer
+       s" menu_init" unsetenv
 ;
 
 \ This function both unsets menu variables and visually erases the menu area
@@ -994,6 +1042,16 @@ bullet menubllt !
 10 menuY !
 5 menuX !
 
+\ Initialize our menu initialization state variables
+0 init_state1 !
+0 init_state2 !
+0 init_state3 !
+0 init_state4 !
+0 init_state5 !
+0 init_state6 !
+0 init_state7 !
+0 init_state8 !
+
 \ Initialize our boolean state variables
 0 toggle_state1 !
 0 toggle_state2 !


>Release-Note:
>Audit-Trail:
>Unformatted:
_______________________________________________
[email protected] mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-bugs
To unsubscribe, send any mail to "[email protected]"

Reply via email to