* Makefile.util.def: Add partmap/msdos.c to common library.
* include/grub/msdos_partition.h: Add GRUB_PC_PARTITION_TYPE_LDM * grub-core/disk/ldm.c: Check for existence of GRUB_PC_PARTITION_TYPE_LDM.
This commit is contained in:
parent
28d468d6f2
commit
b7b78edb1c
4 changed files with 49 additions and 3 deletions
|
@ -22,6 +22,7 @@
|
|||
#include <grub/err.h>
|
||||
#include <grub/misc.h>
|
||||
#include <grub/diskfilter.h>
|
||||
#include <grub/msdos_partition.h>
|
||||
#include <grub/gpt_partition.h>
|
||||
#include <grub/i18n.h>
|
||||
|
||||
|
@ -103,6 +104,37 @@ read_int (grub_uint8_t *in, grub_size_t s)
|
|||
return ret;
|
||||
}
|
||||
|
||||
static int
|
||||
check_ldm_partition (grub_disk_t disk __attribute__ ((unused)), const grub_partition_t p, void *data)
|
||||
{
|
||||
int *has_ldm = data;
|
||||
|
||||
if (p->number >= 4)
|
||||
return 1;
|
||||
if (p->msdostype == GRUB_PC_PARTITION_TYPE_LDM)
|
||||
{
|
||||
*has_ldm = 1;
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
msdos_has_ldm_partition (grub_disk_t dsk)
|
||||
{
|
||||
grub_err_t err;
|
||||
int has_ldm = 0;
|
||||
|
||||
err = grub_partition_msdos_iterate (dsk, check_ldm_partition, &has_ldm);
|
||||
if (err)
|
||||
{
|
||||
grub_errno = GRUB_ERR_NONE;
|
||||
return 0;
|
||||
}
|
||||
|
||||
return has_ldm;
|
||||
}
|
||||
|
||||
static const grub_gpt_part_type_t ldm_type = GRUB_GPT_PARTITION_TYPE_LDM;
|
||||
|
||||
/* Helper for gpt_ldm_sector. */
|
||||
|
@ -760,17 +792,20 @@ grub_ldm_detect (grub_disk_t disk,
|
|||
|
||||
{
|
||||
int i;
|
||||
int has_ldm = msdos_has_ldm_partition (disk);
|
||||
for (i = 0; i < 3; i++)
|
||||
{
|
||||
grub_disk_addr_t sector = LDM_LABEL_SECTOR;
|
||||
switch (i)
|
||||
{
|
||||
case 0:
|
||||
if (!has_ldm)
|
||||
continue;
|
||||
sector = LDM_LABEL_SECTOR;
|
||||
break;
|
||||
case 1:
|
||||
/* LDM is never inside a partition. */
|
||||
if (disk->partition)
|
||||
if (!has_ldm || disk->partition)
|
||||
continue;
|
||||
sector = grub_disk_get_size (disk);
|
||||
if (sector == GRUB_DISK_SIZE_UNKNOWN)
|
||||
|
@ -871,6 +906,7 @@ int
|
|||
grub_util_is_ldm (grub_disk_t disk)
|
||||
{
|
||||
int i;
|
||||
int has_ldm = msdos_has_ldm_partition (disk);
|
||||
for (i = 0; i < 3; i++)
|
||||
{
|
||||
grub_disk_addr_t sector = LDM_LABEL_SECTOR;
|
||||
|
@ -880,11 +916,13 @@ grub_util_is_ldm (grub_disk_t disk)
|
|||
switch (i)
|
||||
{
|
||||
case 0:
|
||||
if (!has_ldm)
|
||||
continue;
|
||||
sector = LDM_LABEL_SECTOR;
|
||||
break;
|
||||
case 1:
|
||||
/* LDM is never inside a partition. */
|
||||
if (disk->partition)
|
||||
if (!has_ldm || disk->partition)
|
||||
continue;
|
||||
sector = grub_disk_get_size (disk);
|
||||
if (sector == GRUB_DISK_SIZE_UNKNOWN)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue