Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 24 Feb 2003 18:27:26 +1100 (EST)
From:      Bruce Evans <bde@zeta.org.au>
To:        Hiten Pandya <hiten@unixdaemons.com>
Cc:        current@FreeBSD.ORG
Subject:   Re: machdep.guessed_bootdev sysctl on i386
Message-ID:  <20030224174824.T5729-100000@gamplex.bde.org>
In-Reply-To: <20030224163424.R5465-100000@gamplex.bde.org>

next in thread | previous in thread | raw e-mail | index | archive | help
On Mon, 24 Feb 2003, I wrote:

> On Sun, 23 Feb 2003, Hiten Pandya wrote:
>
> > Can someone tell me if the machdep.guessed_bootdev sysctl is helpful at
> > all?  I think it's a waste, and it's pretty limited and only available
> > on the i386.
>
> It is not helpful.  Someone removed the initialization of the kernel
> variable bootdev for i386's, so AFAICS bootdev is always unused on i386's
> except for being misinterpreted by sysctl(8).  A variable named bootdev is
> still initialized on sparc64's, but sparc64's don't have the sysctl.

Oops.  I missed that bootdev is initialized in locore.  It is just not
used in the kernel, except to pass the boot block's idea of the boot
device on to userland.  Things work iff userland agrees with the boot
blocks about how the boot device is encoded.

The bug is apaprently that some boot blocks pass the boot device in
an incompatible way.  I can't see the bug.  E.g., boot2 still attempts
to encode "ad" devices with major 30 as is required for backwards
compatibility (booting old kernels) and sideways compatibility
(interpretation by sysctl(8)).

> > It currently guesses 'wd' instead of 'ad' for the dev. nodes, .e.g:
> >
> > 	hiten:~/> sysctl machdep.gussed_bootdev
> > 	machdep.guessed_bootdev: /dev/wd0s1a
> >
> > SCSI drives are shown right (da) but ATA drives mess up, i.e. it is
> > still thinking we have the 'wd' system.  It's either that we nuke this
>
> I don't see how it can work for SCSI drives.  Its kernel variable is
> statically initialized to 0 and never changed on i386's , so its
> sysctl(3) always returns 0 and sysctl(8) always interprets it as "wd".

Now I see how it can work %-).  Is your booting method different for
SCSI drives?

> ...
> I didn't remove the initialization of the kernel bootdev variable for
> i386's in my version and it the sysctl still mostly works for me, but
> for bogus reasons:
> - I use old boot blocks which have old major numbers hard-coded in them.
> - booting works because the kernel ignores the bogus major numbers.
> - sysctl(8) works because its hard-coded old major numbers are the same
>   as the ones in the boot blocks.

I tested with plain -current and old boot blocks.  The sysctl still reports
ad disks correctly.

I don't care about the sysctl but want to keep the boot blocks as
backwards compatible as possible.  That means passing the boot device
in the old encoding, which only takes a couple of lines of code.
Current kernels ignore this and use a device name passed in the
environment.  This is presumably returned by the kenv syscall although
not by a sysctl, so the sysctl is certainly not needed.  I didn't test
this since my boot blocks are too old and simple to pass an environment.
They pass the device name more directly.

Bruce


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




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