From owner-freebsd-arch Sun Dec 23 8:43:59 2001 Delivered-To: freebsd-arch@freebsd.org Received: from tomts16-srv.bellnexxia.net (tomts16.bellnexxia.net [209.226.175.4]) by hub.freebsd.org (Postfix) with ESMTP id E14A137B41A; Sun, 23 Dec 2001 08:43:50 -0800 (PST) Received: from khan.anarcat.dyndns.org ([65.94.189.35]) by tomts16-srv.bellnexxia.net (InterMail vM.4.01.03.16 201-229-121-116-20010115) with ESMTP id <20011223164344.LHAX19575.tomts16-srv.bellnexxia.net@khan.anarcat.dyndns.org>; Sun, 23 Dec 2001 11:43:44 -0500 Received: from shall.anarcat.dyndns.org (shall.anarcat.dyndns.org [192.168.0.1]) by khan.anarcat.dyndns.org (Postfix) with ESMTP id 07BBA1B24; Sun, 23 Dec 2001 11:43:40 -0500 (EST) Received: by shall.anarcat.dyndns.org (Postfix, from userid 1000) id DF51220ACD; Sun, 23 Dec 2001 11:43:37 -0500 (EST) Date: Sun, 23 Dec 2001 11:43:37 -0500 From: The Anarcat To: Poul-Henning Kamp 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> References: <20011222230759.GD530@shall.anarcat.dyndns.org> <61270.1009096630@critter.freebsd.dk> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="wq9mPyueHGvFACwf" Content-Disposition: inline In-Reply-To: <61270.1009096630@critter.freebsd.dk> User-Agent: Mutt/1.3.24i Sender: owner-freebsd-arch@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG --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