Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 27 Dec 2011 17:26:19 -0800
From:      Devin Teske <devin.teske@fisglobal.com>
To:        <freebsd-hackers@freebsd.org>
Cc:        Garrett Cooper <yanegomi@gmail.com>
Subject:   RE: [PATCH] Fix kenv(1) output in w/respect to new boot loader variables
Message-ID:  <02b401ccc4ff$b475b7e0$1d6127a0$@fisglobal.com>

next in thread | raw e-mail | index | archive | help
------=_NextPart_000_02B5_01CCC4BC.A6529EF0
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: 7bit

D'Oh! Attached wrong (OLD; already applied) patch.

Please find appropriate patch attached!

> -----Original Message-----
> From: Devin Teske [mailto:devin.teske@fisglobal.com]
> Sent: Tuesday, December 27, 2011 5:24 PM
> To: 'freebsd-hackers@freebsd.org'
> Cc: Garrett Cooper; devin.teske@fisglobal.com
> Subject: [PATCH] Fix kenv(1) output in w/respect to new boot loader variables
> 
> Garrett Cooper and a few others have requested that I write a patch to fix a
> regression w/respect to kenv(1) output in FreeBSD-9.0 and HEAD.
> 
> The issue is with the new boot loader menu. It adds many loader variables
> including ones that contain ANSI color escapes.
> 
> Obviously, these ANSI codes don't play well with serial consoles when kenv(1)
is
> executed without arguments (reports vary as to what happens, but it's never
> pretty).
> 
> Attached is a patch to the Forth code that clears-out the menu-associated
> variables before invoking the kernel.
> 
> The net-effect is that kenv(1) no longer reports menu-related variables.
> 
> In essence, kenv(1) output should now appear the same as on RELENG_8 (which
> lacks the new boot loader and didn't use any such variables). Thus, restoring
> serial console glory.
> --
> Devin

_____________
The information contained in this message is proprietary and/or confidential. If you are not the intended recipient, please: (i) delete the message and all copies; (ii) do not disclose, distribute or use the message in any manner; and (iii) notify the sender immediately. In addition, please be aware that any message addressed to our domain is subject to archiving and review by persons other than the intended recipient. Thank you.

------=_NextPart_000_02B5_01CCC4BC.A6529EF0
Content-Type: text/plain; name="loader_menu.20111227163902.patch.txt"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: attachment;
	filename="loader_menu.20111227163902.patch.txt"

--- src/sys/boot/forth/menu.4th.8.orig	Tue Dec 27 11:36:25 2011=0A=
+++ src/sys/boot/forth/menu.4th.8	Tue Dec 27 11:41:08 2011=0A=
@@ -24,7 +24,7 @@=0A=
 .\"=0A=
 .\" $FreeBSD: src/sys/boot/forth/menu.4th.8,v 1.2 2011/09/02 19:29:37 =
jh Exp $=0A=
 .\"=0A=
-.Dd Aug 29, 2011=0A=
+.Dd Dec 27, 2011=0A=
 .Dt MENU.4TH 8=0A=
 .Os=0A=
 .Sh NAME=0A=
@@ -69,9 +69,13 @@=0A=
 Calls=0A=
 .Ic menu-erase=0A=
 and then redraws the menu.=0A=
+.It Ic menu-unset=0A=
+Unsets the environment variables associated with individual menu items,=0A=
+clearing the way for a new menu.=0A=
 .It Ic menu-clear=0A=
-Unsets all possible environment variables used=0A=
-to configure the menu and then calls=0A=
+Calls=0A=
+.Ic menu-unset=0A=
+and then=0A=
 .Ic menu-erase .=0A=
 .El=0A=
 .Pp=0A=
--- src/sys/boot/forth/menu.4th.orig	Fri Dec  2 11:17:45 2011=0A=
+++ src/sys/boot/forth/menu.4th	Tue Dec 27 17:09:04 2011=0A=
@@ -131,11 +131,11 @@=0A=
 =0A=
 	\ Print the value of menuidx=0A=
 	loader_color? if=0A=
-		." =1B[1m"=0A=
+		." =1B[1m" ( =1B[22m )=0A=
 	then=0A=
 	menuidx @ .=0A=
 	loader_color? if=0A=
-		." =1B[37m"=0A=
+		." =1B[37m" ( =1B[39m )=0A=
 	then=0A=
 =0A=
 	\ Move the cursor forward 1 column=0A=
@@ -897,22 +897,60 @@=0A=
 ;=0A=
 =0A=
 \ This function unsets all the possible environment variables =
associated with=0A=
-\ creating the interactive menu. Call this when you want to clear the =
menu=0A=
-\ area in preparation for another menu.=0A=
+\ creating the interactive menu.=0A=
 \ =0A=
-: menu-clear ( -- )=0A=
+: menu-unset ( -- )=0A=
 =0A=
 	49 \ Iterator start (loop range 49 to 56; ASCII '1' to '8')=0A=
 	begin=0A=
-		\ basename for caption variable=0A=
-		loader_color? if=0A=
-			s" ansi_caption[x]"=0A=
-		else=0A=
-			s" menu_caption[x]"=0A=
-		then=0A=
+		\ Unset variables in-order of appearance in menu.4th(8)=0A=
+=0A=
+		s" menu_caption[x]"	\ basename for caption variable=0A=
 		-rot 2dup 13 + c! rot	\ replace 'x' with current iteration=0A=
 		unsetenv		\ not erroneous to unset unknown var=0A=
 =0A=
+		s" menu_command[x]"	\ command basename=0A=
+		-rot 2dup 13 + c! rot	\ replace 'x'=0A=
+		unsetenv=0A=
+=0A=
+		s" menu_keycode[x]"	\ keycode basename=0A=
+		-rot 2dup 13 + c! rot	\ replace 'x'=0A=
+		unsetenv=0A=
+=0A=
+		s" ansi_caption[x]"	\ ANSI caption basename=0A=
+		-rot 2dup 13 + c! rot	\ replace 'x'=0A=
+		unsetenv=0A=
+=0A=
+		s" toggled_text[x]"	\ toggle_menuitem caption basename=0A=
+		-rot 2dup 13 + c! rot	\ replace 'x'=0A=
+		unsetenv=0A=
+=0A=
+		s" toggled_ansi[x]"	\ toggle_menuitem ANSI caption basename=0A=
+		-rot 2dup 13 + c! rot	\ replace 'x'=0A=
+		unsetenv=0A=
+=0A=
+		s" menu_caption[x][y]"	\ cycle_menuitem caption=0A=
+		-rot 2dup 13 + c! rot	\ replace 'x'=0A=
+		49 -rot=0A=
+		begin=0A=
+			16 2over rot + c! \ replace 'y'=0A=
+			2dup unsetenv=0A=
+=0A=
+			rot 1+ dup 56 > 2swap rot=0A=
+		until=0A=
+		2drop drop=0A=
+=0A=
+		s" ansi_caption[x][y]"	\ cycle_menuitem ANSI caption=0A=
+		-rot 2dup 13 + c! rot	\ replace 'x'=0A=
+		49 -rot=0A=
+		begin=0A=
+			16 2over rot + c! \ replace 'y'=0A=
+			2dup unsetenv=0A=
+=0A=
+			rot 1+ dup 56 > 2swap rot=0A=
+		until=0A=
+		2drop drop=0A=
+=0A=
 		s" 0 menukeyN !"	\ basename for key association var=0A=
 		-rot 2dup 9 + c! rot	\ replace 'N' with current iteration=0A=
 		evaluate		\ assign zero (0) to key assoc. var=0A=
@@ -921,6 +959,9 @@=0A=
 	until=0A=
 	drop \ iterator=0A=
 =0A=
+	\ unset the timeout command=0A=
+	s" menu_timeout_command" unsetenv=0A=
+=0A=
 	\ clear the "Reboot" menu option flag=0A=
 	s" menu_reboot" unsetenv=0A=
 	0 menureboot !=0A=
@@ -933,6 +974,13 @@=0A=
 	s" menu_options" unsetenv=0A=
 	0 menuoptions !=0A=
 =0A=
+;=0A=
+=0A=
+\ This function both unsets menu variables and visually erases the menu =
area=0A=
+\ in-preparation for another menu.=0A=
+\ =0A=
+: menu-clear ( -- )=0A=
+	menu-unset=0A=
 	menu-erase=0A=
 ;=0A=
 =0A=
--- src/sys/boot/forth/loader.4th.orig	Sun May 29 19:03:52 2011=0A=
+++ src/sys/boot/forth/loader.4th	Tue Dec 27 11:24:55 2011=0A=
@@ -41,12 +41,15 @@=0A=
 =0A=
 include /boot/support.4th=0A=
 =0A=
-\ ***** boot-conf=0A=
-\=0A=
-\	Prepares to boot as specified by loaded configuration files.=0A=
-=0A=
 only forth also support-functions also builtins definitions=0A=
 =0A=
+: try-menu-unset=0A=
+  s" menu-unset"=0A=
+  ['] evaluate catch if=0A=
+    2drop=0A=
+  then=0A=
+;=0A=
+=0A=
 : boot=0A=
   0=3D if ( interpreted ) get_arguments then=0A=
 =0A=
@@ -57,23 +60,31 @@=0A=
       0 1 unload drop=0A=
     else=0A=
       s" kernelname" getenv? if ( a kernel has been loaded )=0A=
+        try-menu-unset=0A=
         1 boot exit=0A=
       then=0A=
       load_kernel_and_modules=0A=
       ?dup if exit then=0A=
+      try-menu-unset=0A=
       0 1 boot exit=0A=
     then=0A=
   else=0A=
     s" kernelname" getenv? if ( a kernel has been loaded )=0A=
+      try-menu-unset=0A=
       1 boot exit=0A=
     then=0A=
     load_kernel_and_modules=0A=
     ?dup if exit then=0A=
+    try-menu-unset=0A=
     0 1 boot exit=0A=
   then=0A=
   load_kernel_and_modules=0A=
   ?dup 0=3D if 0 1 boot then=0A=
 ;=0A=
+=0A=
+\ ***** boot-conf=0A=
+\=0A=
+\	Prepares to boot as specified by loaded configuration files.=0A=
 =0A=
 : boot-conf=0A=
   0=3D if ( interpreted ) get_arguments then=0A=

------=_NextPart_000_02B5_01CCC4BC.A6529EF0--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?02b401ccc4ff$b475b7e0$1d6127a0$>