Date: Sun, 23 Dec 2001 11:43:37 -0500 From: The Anarcat <anarcat@anarcat.dyndns.org> To: Poul-Henning Kamp <phk@critter.freebsd.dk> Cc: arch@FreeBSD.ORG, jkh@FreeBSD.ORG Subject: Re: sysctl kern.disks shouldn't have to sort its output Message-ID: <20011223164336.GA34175@shall.anarcat.dyndns.org> In-Reply-To: <61270.1009096630@critter.freebsd.dk> References: <20011222230759.GD530@shall.anarcat.dyndns.org> <61270.1009096630@critter.freebsd.dk>
next in thread | previous in thread | raw e-mail | index | archive | help
--wq9mPyueHGvFACwf
Content-Type: multipart/mixed; boundary="bp/iNruPH9dso1Pn"
Content-Disposition: inline
--bp/iNruPH9dso1Pn
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable
On Sun Dec 23, 2001 at 09:37:10AM +0100, Poul-Henning Kamp wrote:
> In message <20011222230759.GD530@shall.anarcat.dyndns.org>, The Anarcat w=
rites:
>=20
> >-- snip --
> >revision 1.50.2.14
> >date: 2001/09/18 06:47:30; author: jkh; state: Exp; lines: +2 -2
> >Temporarily disable the use of kern.disks - it returns the disk
> >devices in the wrong order and causes them to be displayed out of
> >sequence in sysinstall.
>=20
>=20
> >To me, the sorting belongs to libdisk at most, or to the user app.
>=20
> ABSOLUTELY!
Yay.
> >Of course, one might wonder why the entries in kern.disks are not
> >sorted. This, I do not know. It might depend on how the disks are
> >detected. For example, here, sysctl kern.disks gives:
> >
> >kern.disks: cd0 ad3 ad1 ad0 md0
>=20
> The reason they are not sorted is that if userland wants them sorted,
> it can be trivially done, whereas nothing in the kernel wants them
> sorted and consequently sorting them in the kernel would be waste
> of time&space.
Arguable, but I agree.
> Not to mention agreeing on what the _right_ sorting order would be:
> disk before CD/DVD ?
> SCSI before ATA ?
> Fixed before removable ?
> BIKESHED!!!!
I prefer my bikeshed to be: lexicographical order. ;)
> >Anyways. If the sorting belongs to the kernel, I could do it.
>=20
> don't.
I did. Patch attached. :) It's simple, really. It just finds a proper
place to add the disk when it is created instead of mindlessly adding it
at the HEAD of the list.
Oh, and if this gets committed, I suggest the removal of the printfs. :)
(let the flamewar begin)
> >However, I think it belongs to libdisk, so I'll start working on a patch
> >there.
>=20
> Yes, please do. That is what Jordan should have done (and was urged to)
> in the first place, but he was afraid that he would b0rk sysinstall doing
> so. Go figure.
Already done. See PR bin/33070 and post on this list.
Someone in his right mind, please commit libdisk or kernel changes, I
don't really care.
I don't think kern.disks was broken in the first place, so *please*
remove that KERN_DISKS_BROKEN crap from the makefile, at least.
that also needs to be MFC'd, IMHO, because it affects the way libdisk
detects drives: normal users can run sysctl kern.disks but not
open(/dev/ad0). So testing libh is a breeze with kern.disks because you
can do everything root can do without the dangerous commit part. :)
BTW: I won't be able to come up with libh boot floppies until after the
vacations, sadly. But I will come up with them at some point. ETA Jan 5.
:)
a.
--bp/iNruPH9dso1Pn
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename=patch
Content-Transfer-Encoding: quoted-printable
Index: subr_disk.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
RCS file: /home/ncvs/src/sys/kern/subr_disk.c,v
retrieving revision 1.20.2.6
diff -u -r1.20.2.6 subr_disk.c
--- subr_disk.c 5 Oct 2001 07:14:57 -0000 1.20.2.6
+++ subr_disk.c 23 Dec 2001 07:32:45 -0000
@@ -47,6 +47,7 @@
disk_create(int unit, struct disk *dp, int flags, struct cdevsw *cdevsw, s=
truct cdevsw *proto)
{
dev_t dev;
+ struct disk *n1, *n2;
=20
bzero(dp, sizeof(*dp));
=20
@@ -70,7 +71,30 @@
dp->d_dev =3D dev;
dp->d_dsflags =3D flags;
dp->d_devsw =3D cdevsw;
- LIST_INSERT_HEAD(&disklist, dp, d_list);
+
+ /* find where we must put this device */
+ n1 =3D LIST_FIRST(&disklist);
+ n2 =3D NULL;
+ /* skip lower devices */
+ while ((n1 !=3D NULL) &&
+ (strcmp(dev->si_name, n1->d_dev->si_name) > 0)) {
+ if (bootverbose)
+ printf("skipping disk %s to order %s\n",
+ n1->d_dev->si_name, dev->si_name);
+ n2 =3D n1;
+ n1 =3D LIST_NEXT(n1, d_list);
+ }
+ if (n2 =3D=3D NULL) {
+ LIST_INSERT_HEAD(&disklist, dp, d_list);
+ if (bootverbose)
+ printf("inserting disk %s at HEAD\n", dev->si_name);
+ } else {
+ LIST_INSERT_AFTER(n2, dp, d_list);
+ if (bootverbose)
+ printf("inserting disk %s after %s (n2)\n",
+ dev->si_name, n2->d_dev->si_name);
+ }
+=09
return (dev);
}
=20
--bp/iNruPH9dso1Pn--
--wq9mPyueHGvFACwf
Content-Type: application/pgp-signature
Content-Disposition: inline
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (FreeBSD)
Comment: For info see http://www.gnupg.org
iEYEARECAAYFAjwmCbgACgkQttcWHAnWiGfyMACgnYmpmNBCjGSX3YO8qwHbn1bm
tqYAnA1qbeqlXiz5OuqviRYZnBeAlqdp
=PuNM
-----END PGP SIGNATURE-----
--wq9mPyueHGvFACwf--
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?20011223164336.GA34175>
