Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 9 Mar 2002 04:27:28 -0800
From:      Luigi Rizzo <rizzo@icir.org>
To:        arch@freebsd.org
Subject:   For review: machdep.bootdev sysctl (for i386)
Message-ID:  <20020309042728.A21016@iguana.icir.org>

next in thread | raw e-mail | index | archive | help
Looking at a way to determine the boot device from userland,
I have come to the conclusion that the most reasonable way is to
export to userland whatever information the kernel has (and this
is machine dependent, sorry!), and let some userland program
(getbootdev(1)) convert it into a reasonable device name.

In the i386 case, the relevant information is in the "bootdev"
variable, defined in i386/i386/autoconf.c and initialized
in i386/i386/locore.s 
In the Alpha case, there is no "bootdev" variable, so I need
feedback from Alpha experts on this.

Unless someone can suggest a better way (i.e. more general
and as little intrusive -- we are talking about a 3-line change
here!) I would like to commit this simple patch, moving bootdev
(which is currently written in locore.s and unused otherwise) to
machdep.c where the SYSCTL hook exports it.

As for the userland program to parse machdep.bootdev, for the time
being i am going to write it as part of the picobsd "tinyware",
pending suggestions on the best place to put it.  There are several
options I can think of, including putting some special code in
sysctl to handle it, much in the same way that is used for some
opaque sysctl variables.

	cheers
	luigi

ndex: autoconf.c
===================================================================
RCS file: /home/ncvs/src/sys/i386/i386/autoconf.c,v
retrieving revision 1.161
diff -u -r1.161 autoconf.c
--- autoconf.c  28 Feb 2002 03:07:35 -0000      1.161
+++ autoconf.c  9 Mar 2002 11:57:21 -0000
@@ -238,8 +238,6 @@
 }
 SYSINIT(cpu_rootconf, SI_SUB_ROOT_CONF, SI_ORDER_FIRST, cpu_rootconf, NULL)
 
-u_long bootdev = 0;            /* not a dev_t - encoding is different */
-
 #if defined(NFSCLIENT) && defined(NFS_ROOT) && !defined(BOOTP_NFSROOT)
 
 static int
Index: machdep.c
===================================================================
RCS file: /home/ncvs/src/sys/i386/i386/machdep.c,v
retrieving revision 1.501
diff -u -r1.501 machdep.c
--- machdep.c   8 Mar 2002 14:31:12 -0000       1.501
+++ machdep.c   9 Mar 2002 12:13:55 -0000
@@ -985,6 +985,10 @@
 SYSCTL_INT(_machdep, CPU_WALLCLOCK, wall_cmos_clock,
        CTLFLAG_RW, &wall_cmos_clock, 0, "");
 
+u_long bootdev;                /* not a dev_t - encoding is different */
+SYSCTL_ULONG(_machdep, OID_AUTO, bootdev,
+       CTLFLAG_RD, &bootdev, 0, "Boot device (not in dev_t format)");
+
 /*
  * Initialize 386 and configure to run kernel
  */


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-arch" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20020309042728.A21016>