From owner-freebsd-hackers Mon Apr 1 10:29: 7 2002 Delivered-To: freebsd-hackers@freebsd.org Received: from albatross.prod.itd.earthlink.net (albatross.mail.pas.earthlink.net [207.217.120.120]) by hub.freebsd.org (Postfix) with ESMTP id 7C37437B400 for ; Mon, 1 Apr 2002 10:28:58 -0800 (PST) Received: from pool0257.cvx21-bradley.dialup.earthlink.net ([209.179.193.2] helo=mindspring.com) by albatross.prod.itd.earthlink.net with esmtp (Exim 3.33 #1) id 16s6Y1-0003du-00; Mon, 01 Apr 2002 10:28:53 -0800 Message-ID: <3CA8A6CE.DBB6CEEB@mindspring.com> Date: Mon, 01 Apr 2002 10:28:30 -0800 From: Terry Lambert X-Mailer: Mozilla 4.7 [en]C-CCK-MCD {Sony} (Win98; U) X-Accept-Language: en MIME-Version: 1.0 To: Dmitry Konyshev Cc: freebsd-hackers@FreeBSD.ORG Subject: Re: finding out boot device References: <84434325847.20020401203442@agava.com> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG Dmitry Konyshev wrote: > Could anyone please tell me if there's any way to find out which > device the system booted from in a user application. The loader > sets loaddev and currdev vars, but I see no way to transfer them to > the user environment. Luigi Rizzo posted patches to communicate this information from the loader to sysctl space. Note that it's not definitive, since you don't get a sure mapping between BIOS devices and protected mode OS device drivers (for obvious reasons). One way to obtain this information is to write a program that uses vm86() calls to read the first N sectors of a BIOS disk, then read the same area using the protected mode drivers. When you get a unique MD5 hash match between the BIOS and the boot device, you're there. For CDROM boots, where the floppy image is in a RAM disk that is wedged into the BIOS calls to replace the floppy, after the boot, the BIOS wedge is destroyed, so that's lost. I guess you could infer this one, if you got no MD5 matches. Good luck with the code; normally, wanting to know this information comes with a bad reason for the desire. 8-). -- Terry To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message