From owner-freebsd-arch Sat Mar 9 22:43:14 2002 Delivered-To: freebsd-arch@freebsd.org Received: from iguana.icir.org (iguana.icir.org [192.150.187.36]) by hub.freebsd.org (Postfix) with ESMTP id A87CC37B400; Sat, 9 Mar 2002 22:43:10 -0800 (PST) Received: (from rizzo@localhost) by iguana.icir.org (8.11.6/8.11.3) id g2A6hAq29071; Sat, 9 Mar 2002 22:43:10 -0800 (PST) (envelope-from rizzo) Date: Sat, 9 Mar 2002 22:43:10 -0800 From: Luigi Rizzo To: Michael Smith Cc: arch@FreeBSD.ORG Subject: Re: For review: machdep.bootdev sysctl (for i386) Message-ID: <20020309224310.A28779@iguana.icir.org> References: <20020309042728.A21016@iguana.icir.org> <200203100456.g2A4u2j01429@mass.dis.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <200203100456.g2A4u2j01429@mass.dis.org> User-Agent: Mutt/1.3.23i 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 Mike, I am not claiming that bootdev gives the correct answer in 100% of the cases. As you correctly notice, there is probably not a "perfect" solution. However, _having tried_ to use it (with the sysctl patch that I posted as a followup, which does essentially the same mapping that is in boot/i386/boot2/boot2.c and presumably was in the ancient i386/i386/autoconf.c), I have to disagree with you on the usefulness of this number. It gives some reasonable information in some common cases, e.g. when you boot off a floppy or a hard disk/CompactFlash slice, and i think it is a big improvement over the current situation where we can only do a blind guess having no information at all. I am not suggesting to use this method as a standard piece of /etc/rc, just make this info available for those users who might have a need for it (and know of its limitations). As I said, if anyone has a better way to do this I'll be glad to hear that. As for the cases I care about (booting PicoBSD, but that would also apply to install disks to make another example), the root device comes from MFS and it is obviously not the root device. So, to summarise: comments received, thanks, we agree on some things, disagree on some others (and I have shown you examples why), and since the gist of my proposal was to export a single kernel variable through sysctl which does not expose any security risk, I do not believe that people should be too upset by this change. For what matters, we already export lots of stuff (such as machdep.bootinfo, debug.boothowto, debug.sizeof.*). of questionable usefulness (to me, but then others might have some use for this information). cheers luigi On Sat, Mar 09, 2002 at 08:56:02PM -0800, Michael Smith wrote: > > 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. > > What do you mean by "boot device"? > > The device from which the initial bootstrap was loaded? The device from > which the loader was loaded? The device from which the kernel was loaded? > > There's really no such thing. > > > 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 > > This is unreliable; it's usually but not always the BIOS unit number for > the "current" disk, which may or may not be any of the above "boot > devices". > > > In the Alpha case, there is no "bootdev" variable, so I need > > feedback from Alpha experts on this. > > There is no way (that I am aware of) to extract the SRM name of the > booted device. > > > 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. > > I think that this is not a good way to do things. Exporting this number > is not useful, and based on my current reservations, I would strongly > oppose any attempt to use it for anything. > > > 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. > > I can't imagine how you plan to do this and make it reliable, since there > is no mapping from BIOS unit numbers to BSD devices. In almost any case > you are likely to care about, the "boot device" is also the root device. > > Detecting, let alone doing anything useful about, the other cases is IME > an impossible proposition. > > = Mike > > -- > To announce that there must be no criticism of the president, > or that we are to stand by the president, right or wrong, is not > only unpatriotic and servile, but is morally treasonable to > the American public. - Theodore Roosevelt > > > > To Unsubscribe: send mail to majordomo@FreeBSD.org > with "unsubscribe freebsd-arch" in the body of the message To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-arch" in the body of the message