Unbreak booting from the true dedicated disks.

When we open the disk, check the type of partition table, that has
been detected. If this is BSD label, then we assume this is DD mode.

Reported by:	dim@
This commit is contained in:
Andrey V. Elsukov 2012-08-13 13:08:30 +00:00
parent 347c7fd7bf
commit 42b577fe76
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=239230
2 changed files with 14 additions and 3 deletions

View File

@ -173,7 +173,13 @@ disk_open(struct disk_devdesc *dev, off_t mediasize, u_int sectorsize)
rc = ENXIO;
goto out;
}
if (dev->d_slice > 0) {
if (ptable_gettype(od->table) == PTABLE_BSD &&
dev->d_partition >= 0) {
/* It doesn't matter what value has d_slice */
rc = ptable_getpart(od->table, &part, dev->d_partition);
if (rc == 0)
dev->d_offset = part.start;
} else if (dev->d_slice > 0) {
/* Try to get information about partition */
rc = ptable_getpart(od->table, &part, dev->d_slice);
if (rc != 0) /* Partition doesn't exist */
@ -247,9 +253,9 @@ disk_fmtdev(struct disk_devdesc *dev)
#ifdef LOADER_MBR_SUPPORT
cp += sprintf(cp, "s%d", dev->d_slice);
#endif
if (dev->d_partition >= 0)
cp += sprintf(cp, "%c", dev->d_partition + 'a');
}
if (dev->d_partition >= 0)
cp += sprintf(cp, "%c", dev->d_partition + 'a');
strcat(cp, ":");
return (buf);
}

View File

@ -45,6 +45,11 @@
* d_slice = MBR slice number (typically 1..4)
* d_partition = disklabel partition (typically 0..7)
*
* BSD disklabel partition on the true dedicated disk:
*
* d_slice = -1
* d_partition = disklabel partition (typically 0..7)
*
* GPT partition:
*
* d_slice = GPT partition number (typically 1..N)