From dcs@newsguy.com  Tue Jan 12 09:38:58 1999
Received: from peach.ocn.ne.jp (peach.ocn.ne.jp [210.145.254.87])
          by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id JAA16280
          for <FreeBSD-gnats-submit@freebsd.org>; Tue, 12 Jan 1999 09:38:57 -0800 (PST)
          (envelope-from dcs@newsguy.com)
Received: from daniel.sobral by peach.ocn.ne.jp (8.9.1a/OCN) id CAA05891; Wed, 13 Jan 1999 02:38:21 +0900 (JST)
Received: (from root@localhost)
	by daniel.sobral (8.9.1/8.9.1) id CAA00626;
	Wed, 13 Jan 1999 02:38:01 +0900 (JST)
	(envelope-from root)
Message-Id: <199901121738.CAA00626@daniel.sobral>
Date: Wed, 13 Jan 1999 02:38:01 +0900 (JST)
From: dcs@newsguy.com
Reply-To: dcs@newsguy.com
To: FreeBSD-gnats-submit@freebsd.org
Subject: Loader can't identify it's version
X-Send-Pr-Version: 3.2

>Number:         9460
>Category:       kern
>Synopsis:       Loader can't tell a program what it's version is
>Confidential:   no
>Severity:       non-critical
>Priority:       high
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Tue Jan 12 09:40:00 PST 1999
>Closed-Date:    Fri Jan 22 15:56:03 PST 1999
>Last-Modified:  Fri Jan 22 15:56:26 PST 1999
>Originator:     Daniel C. Sobral
>Release:        FreeBSD 3.0-CURRENT i386
>Organization:
>Environment:

	Current as of Jan 12/1999, three stage boot's loader.

>Description:

	There is no way a program can properly tell precisely what
version it of loader it is running on. This path leads to hacks an
eventual complete incompatibilities.

>How-To-Repeat:

	UTSL.

>Fix:

	The patch below creates a Forth "environment" variable.
These are accessed by the standard Forth word "environment?", and
are used to determine characteristics about the system (like char
and cell sizes, word sets supported, etc). The fix below sets a
"loader-version" environment variable to 3100, which I'm thinking
of as being FreeBSD's version. It need not need to be the same
as FreeBSD's version, but, this way, it gives *extra* information
to the loader, which, of course, can be *completely* incorrect,
as the loader doesn't necessarily reflect the world's version,
even if it *is* installed by it. :-) Still, it can be used to
tell ficl programs in what version of loader they are running in.

	Also, notice that I hardcoded 3100. I discarded almost
instantly using a macro because I knew I'd most surely get it
wrong anyway. :-)

	Finally, there are *two* patch files below. The first
apply to my kern/9412 interp_forth.c, and the second to a
current as of Jan 12 interp_forth.c.

--- interp_forth.c	1999/01/11 17:31:47	1.5
+++ interp_forth.c	1999/01/12 17:26:20	1.7
@@ -23,7 +23,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- *	$Id: interp_forth.c,v 1.5 1999/01/11 17:31:47 root Exp $
+ *	$Id: interp_forth.c,v 1.7 1999/01/12 17:26:20 root Exp $
  */
 
 #include <string.h>
@@ -137,6 +137,9 @@
 	sprintf(create_buf, "builtin: %s", (*cmdp)->c_name);
 	ficlExec(bf_vm, create_buf, -1);
     }
+
+    /* Set the version number */
+    ficlSetEnv("loader-version", 3100);
 
     /* try to load and run init file if present */
     if ((fd = open("/boot/boot.4th", O_RDONLY)) != -1) {
--- interp_forth.c	1999/01/12 14:43:46	1.1.2.1
+++ interp_forth.c	1999/01/12 17:27:05	1.1.2.3
@@ -23,7 +23,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- *	$Id: interp_forth.c,v 1.1.2.1 1999/01/12 14:43:46 root Exp $
+ *	$Id: interp_forth.c,v 1.1.2.3 1999/01/12 17:27:05 root Exp $
  */
 
 #include <string.h>
@@ -118,6 +118,9 @@
     /* make all commands appear as Forth words */
     SET_FOREACH(cmdp, Xcommand_set)
 	ficlBuild((*cmdp)->c_name, bf_command, FW_DEFAULT);
+
+    /* Set the version number */
+    ficlSetEnv("loader-version", 3100);
 
     /* try to load and run init file if present */
     if ((fd = open("/boot/boot.4th", O_RDONLY)) != -1) {

>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->closed 
State-Changed-By: msmith 
State-Changed-When: Fri Jan 22 15:56:03 PST 1999 
State-Changed-Why:  
Basic idea adopted, two variables added. 
>Unformatted:
