diff options
| author | Andrey V. Elsukov <ae@FreeBSD.org> | 2012-09-28 10:49:41 +0000 |
|---|---|---|
| committer | Andrey V. Elsukov <ae@FreeBSD.org> | 2012-09-28 10:49:41 +0000 |
| commit | 88a0dd24bf503b18f98b8596330b59777f56b662 (patch) | |
| tree | 4c8602bd4b8c2c6a4b3e4c70bf9953627a02e04b /sys/boot/common | |
| parent | 5d8a6a1078838009d10d494dcd86ca6e77710f98 (diff) | |
Notes
Diffstat (limited to 'sys/boot/common')
| -rw-r--r-- | sys/boot/common/disk.c | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/sys/boot/common/disk.c b/sys/boot/common/disk.c index c7716d3ac1ed..0389956f5366 100644 --- a/sys/boot/common/disk.c +++ b/sys/boot/common/disk.c @@ -179,12 +179,21 @@ disk_open(struct disk_devdesc *dev, off_t mediasize, u_int sectorsize) rc = ptable_getpart(od->table, &part, dev->d_partition); if (rc == 0) dev->d_offset = part.start; - } else if (dev->d_slice > 0) { + } else if (dev->d_slice >= 0) { /* Try to get information about partition */ - rc = ptable_getpart(od->table, &part, dev->d_slice); + if (dev->d_slice == 0) + rc = ptable_getbestpart(od->table, &part); + else + rc = ptable_getpart(od->table, &part, dev->d_slice); if (rc != 0) /* Partition doesn't exist */ goto out; dev->d_offset = part.start; + if (dev->d_slice == 0) { + /* Save the slice number of best partition to dev */ + dev->d_slice = part.index; + if (ptable_gettype(od->table) == PTABLE_GPT) + dev->d_partition = 255; + } if (dev->d_partition == 255) goto out; /* Nothing more to do */ /* @@ -217,13 +226,6 @@ disk_open(struct disk_devdesc *dev, off_t mediasize, u_int sectorsize) if (rc != 0) goto out; dev->d_offset += part.start; - } else if (dev->d_slice == 0) { - rc = ptable_getbestpart(od->table, &part); - if (rc != 0) - goto out; - /* Save the slice number of best partition to dev */ - dev->d_slice = part.index; - dev->d_offset = part.start; } out: if (table != NULL) |
