Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 24 Feb 2003 17:04:16 +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:  <20030224163424.R5465-100000@gamplex.bde.org>
In-Reply-To: <20030224024210.GA50286@unixdaemons.com>

next in thread | previous in thread | raw e-mail | index | archive | help
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.

> 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".

> sysctl or apply the attached patch to sysctl, which has been reviewed
> and tested by people on IRC with positive results.

% Index: src/sbin/sysctl/sysctl.c
% ===================================================================
% RCS file: /home/ncvs/src/sbin/sysctl/sysctl.c,v
% retrieving revision 1.51
% diff -u -r1.51 sysctl.c
% --- src/sbin/sysctl/sysctl.c	22 Jan 2003 00:34:22 -0000	1.51
% +++ src/sbin/sysctl/sysctl.c	22 Feb 2003 14:21:13 -0000
% @@ -460,9 +460,7 @@
%  	int majdev;
%  	char *name;
%  } maj2name[] = {
% -	30,	"ad",
% -	0,	"wd",
% -	1,	"wfd",
% +	0,	"ad",
%  	2,	"fd",
%  	4,	"da",
%  	-1,	NULL	/* terminator */

This table and the corresponding function are very bogus, and can be
simplified to always printing "wd0<mumble>" in the old broken version,
and always "ad0<mumble>" in the new broken version.  0 certainly isn't
ad's major number.  All of the major numbers in this table rotted long
ago.  They are major numbers for block devices, but block devices were
axed in FreeBSD-4.0.

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.

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?20030224163424.R5465-100000>