Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 01 Apr 2002 10:28:30 -0800
From:      Terry Lambert <tlambert2@mindspring.com>
To:        Dmitry Konyshev <daemon@agava.com>
Cc:        freebsd-hackers@FreeBSD.ORG
Subject:   Re: finding out boot device
Message-ID:  <3CA8A6CE.DBB6CEEB@mindspring.com>
References:  <84434325847.20020401203442@agava.com>

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




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?3CA8A6CE.DBB6CEEB>