or
or
By clicking below, you agree to our terms of service.
New to HackMD? Sign up
Syntax | Example | Reference | |
---|---|---|---|
# Header | Header | 基本排版 | |
- Unordered List |
|
||
1. Ordered List |
|
||
- [ ] Todo List |
|
||
> Blockquote | Blockquote |
||
**Bold font** | Bold font | ||
*Italics font* | Italics font | ||
~~Strikethrough~~ | |||
19^th^ | 19th | ||
H~2~O | H2O | ||
++Inserted text++ | Inserted text | ||
==Marked text== | Marked text | ||
[link text](https:// "title") | Link | ||
 | Image | ||
`Code` | Code |
在筆記中貼入程式碼 | |
```javascript var i = 0; ``` |
|
||
:smile: | ![]() |
Emoji list | |
{%youtube youtube_id %} | Externals | ||
$L^aT_eX$ | LaTeX | ||
:::info This is a alert area. ::: |
This is a alert area. |
On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?
Please give us some advice and help us improve HackMD.
Do you want to remove this version name and description?
Syncing
xxxxxxxxxx
In x86/x86_autoconf.c.
findroot()
attempts to find the device (adevice_t
) from which the kernel was loaded and changesrootdev
(anotherdevice_t
), if allowed to do so.It does this in 6 steps:
booted_device
(adevice_t
) is already set, it just returns, not settingrootdev
. The assumption seems to be, that the kernel was booted from the network anddevice_register()
already has setbooted_device
.BTINFO_NETIF
is available (butbooted_device
isn't set), it just returns, logging a message that the netboot interface wasn't found.BTINFO_ROOTDEVICE
is non-NULL.biv->devname
is expected to be of the form"drivername<unitdigit><partitionletter>"
.It loops over all disk devices looking for a device who's
cfname
is the same asdrivername
.Iff such a device is found it sets the following variables:
partitionletter
"bootinfo/rootdevice"
If it does not find a matching device(
dv
beingNULL
after exiting the loop) andbiv->devname
is not the empty string (biv->devname[0] != '\0'
) it copies the devname tobootspec
and returns.BUGS Note that we can't boot off e.g. sd10 and that the nonsense is stored in
booted_partition
if the last character ofbiv->devname
is not a valid partition letter ('a'-'v' c.f. sys/disklabel.h). In particular: "sd0z" and "sd0", in the latter case the "partition letter" is the NUL character terminating the device name.This is handled better in the xen_machdep.c.
XXX there was other code that converted device unit with strtod(). But where?
4.
BTINFO_BOOTWEDGE
is non-NULLbiw->biosdev
is expected to have the0x80
bit set, indicating a hard disk. XXX why? Possibly because we floppies don't have wedges.BTINFO_BOOTDISK
should be available.It loops over all the disk devices looking for disk with
is_valid_disk()
thatmatch_bootwedge()
the device.match_bootwedge()
calculates the MD5 hash of the device blocksbiw->matchblk
tobiw->matchblk+biw->matchnblks
returning true if that hash is equal tobiw->matchhash
.biw->matchblk == -1
indicates that no sector(block) was specified, hence no match.XXX why not compare just devclass as in
BTINFO_ROOTDEVICE
case?If a matching device was found the following variables are set:
bid->partition
ifBTINFO_BOOTDISK
was available, else0
biw->nblks
(possibly0
) XXX when?biw->startblk
, the starting block of the partition"bootinfo/bootwedge"
BTINFO_BOOTDISK
is non-NULLIt loops over all disk and floppy devices, looking for either a floppy device who's
device_unit
is equal tobid->biosdev
or a disk who's disklabel's type, checksum, and packname match the information passed inbid->label
(viamatch_bootdisk()
).It sets the following variables:
device_t
of the device that the kernel was loaded frombid->partition
0
, indicating that no geometry was passed"bootinfo/bootdisk"
BTINFO_BIOSGEOM
is non-NULL andbid->biosdev
indicates a CDROM (by being bigger than the number of biosgeom entries declared by the BIOS).It find the first CDROM device and sets the following variables:
device_t
of the first probed CDROM0
0
, indicating that bios geometry is not relevant"bootinfo/biosgeom"
findroot()
return without setting any variables.Summary: it stores the device from where the system was booted from, in
booted_device
, along with other device associated variables. it does this in one of 4 cases (types of booting method) . those cases are true if bootinfo of bootloader has information corresponding to their type. if the bootinfo has no information regarding those types of bootmethod it returns without setting any varibles.